[Debug Trait] Comments and Cleanup

.
This commit is contained in:
Poly 2021-02-22 21:05:00 +01:00
parent de3dfacee0
commit 6d76d1c1a2
17 changed files with 20 additions and 29 deletions

View File

@ -60,6 +60,7 @@ pub struct AtomicDrmDevice<A: AsRawFd + 'static> {
logger: ::slog::Logger, logger: ::slog::Logger,
} }
// DeviceHandler does not implement Debug, so we have to impl Debug manually
impl<A: AsRawFd + fmt::Debug + 'static> fmt::Debug for AtomicDrmDevice<A> { impl<A: AsRawFd + fmt::Debug + 'static> fmt::Debug for AtomicDrmDevice<A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut debug = f.debug_struct("AtomicDrmDevice"); let mut debug = f.debug_struct("AtomicDrmDevice");
@ -92,6 +93,7 @@ type Mapping = (
HashMap<plane::Handle, HashMap<String, property::Handle>>, HashMap<plane::Handle, HashMap<String, property::Handle>>,
); );
#[derive(Debug)]
pub(in crate::backend::drm) struct Dev<A: AsRawFd + 'static> { pub(in crate::backend::drm) struct Dev<A: AsRawFd + 'static> {
fd: A, fd: A,
privileged: bool, privileged: bool,
@ -101,19 +103,6 @@ pub(in crate::backend::drm) struct Dev<A: AsRawFd + 'static> {
logger: ::slog::Logger, logger: ::slog::Logger,
} }
impl<A: AsRawFd + fmt::Debug + 'static> fmt::Debug for Dev<A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Dev")
.field("fd", &self.fd)
.field("privileged", &self.privileged)
.field("active", &self.active)
.field("old_state", &self.old_state)
.field("prop_mapping", &self.prop_mapping)
.field("logger", &self.logger)
.finish()
}
}
impl<A: AsRawFd + 'static> AsRawFd for Dev<A> { impl<A: AsRawFd + 'static> AsRawFd for Dev<A> {
fn as_raw_fd(&self) -> RawFd { fn as_raw_fd(&self) -> RawFd {
self.fd.as_raw_fd() self.fd.as_raw_fd()

View File

@ -7,7 +7,6 @@ use drm::control::{
use drm::Device as BasicDevice; use drm::Device as BasicDevice;
use std::collections::HashSet; use std::collections::HashSet;
use std::fmt;
use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::io::{AsRawFd, RawFd};
use std::sync::{atomic::Ordering, Arc, Mutex, RwLock}; use std::sync::{atomic::Ordering, Arc, Mutex, RwLock};
@ -37,6 +36,7 @@ pub struct Planes {
pub cursor: plane::Handle, pub cursor: plane::Handle,
} }
#[derive(Debug)]
pub(in crate::backend::drm) struct AtomicDrmSurfaceInternal<A: AsRawFd + 'static> { pub(in crate::backend::drm) struct AtomicDrmSurfaceInternal<A: AsRawFd + 'static> {
pub(super) dev: Arc<Dev<A>>, pub(super) dev: Arc<Dev<A>>,
pub(in crate::backend::drm) crtc: crtc::Handle, pub(in crate::backend::drm) crtc: crtc::Handle,
@ -48,21 +48,6 @@ pub(in crate::backend::drm) struct AtomicDrmSurfaceInternal<A: AsRawFd + 'static
pub(super) test_buffer: Mutex<Option<(DumbBuffer, framebuffer::Handle)>>, pub(super) test_buffer: Mutex<Option<(DumbBuffer, framebuffer::Handle)>>,
} }
impl<A: AsRawFd + fmt::Debug + 'static> fmt::Debug for AtomicDrmSurfaceInternal<A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("AtomicDrmSurfaceInternal")
.field("dev", &self.dev)
.field("crtc", &self.crtc)
.field("cursor", &self.cursor)
.field("planse", &self.planes)
.field("state", &self.state)
.field("pending", &self.pending)
.field("logger", &self.logger)
.field("test_buffer", &self.test_buffer)
.finish()
}
}
impl<A: AsRawFd + 'static> AsRawFd for AtomicDrmSurfaceInternal<A> { impl<A: AsRawFd + 'static> AsRawFd for AtomicDrmSurfaceInternal<A> {
fn as_raw_fd(&self) -> RawFd { fn as_raw_fd(&self) -> RawFd {
self.dev.as_raw_fd() self.dev.as_raw_fd()

View File

@ -50,6 +50,7 @@ pub enum FallbackDevice<D1: Device + 'static, D2: Device + 'static> {
Fallback(D2), Fallback(D2),
} }
// Device is a trait, so we have to impl Debug manually
impl<D1: Device + 'static, D2: Device + 'static> fmt::Debug for FallbackDevice<D1, D2> { impl<D1: Device + 'static, D2: Device + 'static> fmt::Debug for FallbackDevice<D1, D2> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
@ -152,6 +153,7 @@ pub enum FallbackSurface<S1: Surface, S2: Surface> {
Fallback(S2), Fallback(S2),
} }
// Surface is a trait, so we have to impl Debug manually
impl<S1: Surface, S2: Surface> fmt::Debug for FallbackSurface<S1, S2> { impl<S1: Surface, S2: Surface> fmt::Debug for FallbackSurface<S1, S2> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {

View File

@ -70,6 +70,7 @@ where
links: Vec<crate::signaling::SignalToken>, links: Vec<crate::signaling::SignalToken>,
} }
// BackendRef does not implement debug, so we have to impl Debug manually
impl<B, D> fmt::Debug for EglDevice<B, D> impl<B, D> fmt::Debug for EglDevice<B, D>
where where
B: Backend<Surface = <D as Device>::Surface, Error = <<D as Device>::Surface as Surface>::Error> B: Backend<Surface = <D as Device>::Surface, Error = <<D as Device>::Surface as Surface>::Error>

View File

@ -91,6 +91,7 @@ pub struct EglStreamDevice<D: RawDevice + ControlDevice + 'static> {
links: Vec<crate::signaling::SignalToken>, links: Vec<crate::signaling::SignalToken>,
} }
// SurfaceInternalRef does not implement debug, so we have to impl Debug manually
impl<D: RawDevice + ControlDevice + fmt::Debug + 'static> fmt::Debug for EglStreamDevice<D> { impl<D: RawDevice + ControlDevice + fmt::Debug + 'static> fmt::Debug for EglStreamDevice<D> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut debug = f.debug_struct("EglStreamDevice"); let mut debug = f.debug_struct("EglStreamDevice");

View File

@ -457,6 +457,7 @@ pub struct EGLBufferReader {
gl: gl_ffi::Gles2, gl: gl_ffi::Gles2,
} }
// Gles2 does not implement debug, so we have to impl Debug manually
#[cfg(feature = "use_system_lib")] #[cfg(feature = "use_system_lib")]
impl fmt::Debug for EGLBufferReader { impl fmt::Debug for EGLBufferReader {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

View File

@ -269,6 +269,7 @@ pub struct EGLImages {
gl: gl_ffi::Gles2, gl: gl_ffi::Gles2,
} }
// Gles2 does not implement debug, so we have to impl Debug manually
#[cfg(feature = "wayland_frontend")] #[cfg(feature = "wayland_frontend")]
impl fmt::Debug for EGLImages { impl fmt::Debug for EGLImages {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

View File

@ -23,6 +23,7 @@ pub struct GliumGraphicsBackend<T: GLGraphicsBackend> {
error_channel: Rc<Cell<Option<Box<dyn std::error::Error>>>>, error_channel: Rc<Cell<Option<Box<dyn std::error::Error>>>>,
} }
// GLGraphicsBackend is a trait, so we have to impl Debug manually
impl<T: GLGraphicsBackend> fmt::Debug for GliumGraphicsBackend<T> { impl<T: GLGraphicsBackend> fmt::Debug for GliumGraphicsBackend<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
struct BackendDebug<'a, T: GLGraphicsBackend>(&'a Rc<InternalBackend<T>>); struct BackendDebug<'a, T: GLGraphicsBackend>(&'a Rc<InternalBackend<T>>);

View File

@ -427,6 +427,7 @@ impl From<event::pointer::ButtonState> for backend::MouseButtonState {
#[cfg(feature = "backend_session")] #[cfg(feature = "backend_session")]
pub struct LibinputSessionInterface<S: Session>(S); pub struct LibinputSessionInterface<S: Session>(S);
// Session is a trait, so we have to impl Debug manually
#[cfg(feature = "backend_session")] #[cfg(feature = "backend_session")]
impl<S: Session> fmt::Debug for LibinputSessionInterface<S> { impl<S: Session> fmt::Debug for LibinputSessionInterface<S> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

View File

@ -71,6 +71,7 @@ struct LogindSessionImpl {
logger: ::slog::Logger, logger: ::slog::Logger,
} }
// DBusConnection does not implement debug, so we have to impl Debug manually
impl fmt::Debug for LogindSessionImpl { impl fmt::Debug for LogindSessionImpl {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("LogindSessionImpl ") f.debug_struct("LogindSessionImpl ")

View File

@ -63,6 +63,7 @@ pub struct UdevBackend {
logger: ::slog::Logger, logger: ::slog::Logger,
} }
// MonitorSocket does not implement debug, so we have to impl Debug manually
impl fmt::Debug for UdevBackend { impl fmt::Debug for UdevBackend {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use udev::AsRaw; use udev::AsRaw;

View File

@ -66,6 +66,7 @@ enum Window {
}, },
} }
// WlEglSurface does not implement debug, so we have to impl Debug manually
impl fmt::Debug for Window { impl fmt::Debug for Window {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {

View File

@ -111,6 +111,7 @@ struct SignalInner<S> {
pending_events: RefCell<VecDeque<S>>, pending_events: RefCell<VecDeque<S>>,
} }
// WeakCallback does not implement debug, so we have to impl Debug manually
impl<S: fmt::Debug> fmt::Debug for SignalInner<S> { impl<S: fmt::Debug> fmt::Debug for SignalInner<S> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SignalInner") f.debug_struct("SignalInner")

View File

@ -172,6 +172,7 @@ pub struct SurfaceAttributes {
pub user_data: UserDataMap, pub user_data: UserDataMap,
} }
// UserDataMap does not implement debug, so we have to impl Debug manually
impl fmt::Debug for SurfaceAttributes { impl fmt::Debug for SurfaceAttributes {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SurfaceAttributes") f.debug_struct("SurfaceAttributes")

View File

@ -120,6 +120,7 @@ struct KbdInternal {
focus_hook: Box<dyn FnMut(Option<&WlSurface>)>, focus_hook: Box<dyn FnMut(Option<&WlSurface>)>,
} }
// focus_hook does not implement debug, so we have to impl Debug manually
impl fmt::Debug for KbdInternal { impl fmt::Debug for KbdInternal {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("KbdInternal") f.debug_struct("KbdInternal")

View File

@ -74,6 +74,7 @@ pub(crate) struct SeatRc {
name: String, name: String,
} }
// UserDataMap does not implement debug, so we have to impl Debug manually
impl fmt::Debug for SeatRc { impl fmt::Debug for SeatRc {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SeatRc") f.debug_struct("SeatRc")

View File

@ -35,6 +35,7 @@ enum GrabStatus {
Borrowed, Borrowed,
} }
// PointerGrab is a trait, so we have to impl Debug manually
impl fmt::Debug for GrabStatus { impl fmt::Debug for GrabStatus {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
@ -55,6 +56,7 @@ struct PointerInternal {
image_callback: Box<dyn FnMut(CursorImageStatus)>, image_callback: Box<dyn FnMut(CursorImageStatus)>,
} }
// image_callback does not implement debug, so we have to impl Debug manually
impl fmt::Debug for PointerInternal { impl fmt::Debug for PointerInternal {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Point") f.debug_struct("Point")