From 6d76d1c1a27f2f28785acf2a9bb9b7f3201daa12 Mon Sep 17 00:00:00 2001 From: Poly Date: Mon, 22 Feb 2021 21:05:00 +0100 Subject: [PATCH] [Debug Trait] Comments and Cleanup . --- src/backend/drm/atomic/mod.rs | 15 ++------------- src/backend/drm/atomic/surface.rs | 17 +---------------- src/backend/drm/common/fallback.rs | 2 ++ src/backend/drm/egl/mod.rs | 1 + src/backend/drm/eglstream/mod.rs | 1 + src/backend/egl/display.rs | 1 + src/backend/egl/mod.rs | 1 + src/backend/graphics/glium.rs | 1 + src/backend/libinput/mod.rs | 1 + src/backend/session/dbus/logind.rs | 1 + src/backend/udev.rs | 1 + src/backend/winit.rs | 1 + src/signaling.rs | 1 + src/wayland/compositor/mod.rs | 1 + src/wayland/seat/keyboard.rs | 1 + src/wayland/seat/mod.rs | 1 + src/wayland/seat/pointer.rs | 2 ++ 17 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/backend/drm/atomic/mod.rs b/src/backend/drm/atomic/mod.rs index dcaf7d4..38e2e71 100644 --- a/src/backend/drm/atomic/mod.rs +++ b/src/backend/drm/atomic/mod.rs @@ -60,6 +60,7 @@ pub struct AtomicDrmDevice { logger: ::slog::Logger, } +// DeviceHandler does not implement Debug, so we have to impl Debug manually impl fmt::Debug for AtomicDrmDevice { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut debug = f.debug_struct("AtomicDrmDevice"); @@ -92,6 +93,7 @@ type Mapping = ( HashMap>, ); +#[derive(Debug)] pub(in crate::backend::drm) struct Dev { fd: A, privileged: bool, @@ -101,19 +103,6 @@ pub(in crate::backend::drm) struct Dev { logger: ::slog::Logger, } -impl fmt::Debug for Dev { - 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 AsRawFd for Dev { fn as_raw_fd(&self) -> RawFd { self.fd.as_raw_fd() diff --git a/src/backend/drm/atomic/surface.rs b/src/backend/drm/atomic/surface.rs index fc05cee..9946858 100644 --- a/src/backend/drm/atomic/surface.rs +++ b/src/backend/drm/atomic/surface.rs @@ -7,7 +7,6 @@ use drm::control::{ use drm::Device as BasicDevice; use std::collections::HashSet; -use std::fmt; use std::os::unix::io::{AsRawFd, RawFd}; use std::sync::{atomic::Ordering, Arc, Mutex, RwLock}; @@ -37,6 +36,7 @@ pub struct Planes { pub cursor: plane::Handle, } +#[derive(Debug)] pub(in crate::backend::drm) struct AtomicDrmSurfaceInternal { pub(super) dev: Arc>, pub(in crate::backend::drm) crtc: crtc::Handle, @@ -48,21 +48,6 @@ pub(in crate::backend::drm) struct AtomicDrmSurfaceInternal>, } -impl fmt::Debug for AtomicDrmSurfaceInternal { - 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 AsRawFd for AtomicDrmSurfaceInternal { fn as_raw_fd(&self) -> RawFd { self.dev.as_raw_fd() diff --git a/src/backend/drm/common/fallback.rs b/src/backend/drm/common/fallback.rs index d86aed8..306b7b6 100644 --- a/src/backend/drm/common/fallback.rs +++ b/src/backend/drm/common/fallback.rs @@ -50,6 +50,7 @@ pub enum FallbackDevice { Fallback(D2), } +// Device is a trait, so we have to impl Debug manually impl fmt::Debug for FallbackDevice { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -152,6 +153,7 @@ pub enum FallbackSurface { Fallback(S2), } +// Surface is a trait, so we have to impl Debug manually impl fmt::Debug for FallbackSurface { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { diff --git a/src/backend/drm/egl/mod.rs b/src/backend/drm/egl/mod.rs index 0261058..36633ac 100644 --- a/src/backend/drm/egl/mod.rs +++ b/src/backend/drm/egl/mod.rs @@ -70,6 +70,7 @@ where links: Vec, } +// BackendRef does not implement debug, so we have to impl Debug manually impl fmt::Debug for EglDevice where B: Backend::Surface, Error = <::Surface as Surface>::Error> diff --git a/src/backend/drm/eglstream/mod.rs b/src/backend/drm/eglstream/mod.rs index c579c2c..869127d 100644 --- a/src/backend/drm/eglstream/mod.rs +++ b/src/backend/drm/eglstream/mod.rs @@ -91,6 +91,7 @@ pub struct EglStreamDevice { links: Vec, } +// SurfaceInternalRef does not implement debug, so we have to impl Debug manually impl fmt::Debug for EglStreamDevice { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut debug = f.debug_struct("EglStreamDevice"); diff --git a/src/backend/egl/display.rs b/src/backend/egl/display.rs index 6012a3b..fc26adf 100644 --- a/src/backend/egl/display.rs +++ b/src/backend/egl/display.rs @@ -457,6 +457,7 @@ pub struct EGLBufferReader { gl: gl_ffi::Gles2, } +// Gles2 does not implement debug, so we have to impl Debug manually #[cfg(feature = "use_system_lib")] impl fmt::Debug for EGLBufferReader { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/src/backend/egl/mod.rs b/src/backend/egl/mod.rs index f03c311..a6d1ea3 100644 --- a/src/backend/egl/mod.rs +++ b/src/backend/egl/mod.rs @@ -269,6 +269,7 @@ pub struct EGLImages { gl: gl_ffi::Gles2, } +// Gles2 does not implement debug, so we have to impl Debug manually #[cfg(feature = "wayland_frontend")] impl fmt::Debug for EGLImages { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/src/backend/graphics/glium.rs b/src/backend/graphics/glium.rs index 8168ab5..96f2226 100644 --- a/src/backend/graphics/glium.rs +++ b/src/backend/graphics/glium.rs @@ -23,6 +23,7 @@ pub struct GliumGraphicsBackend { error_channel: Rc>>>, } +// GLGraphicsBackend is a trait, so we have to impl Debug manually impl fmt::Debug for GliumGraphicsBackend { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { struct BackendDebug<'a, T: GLGraphicsBackend>(&'a Rc>); diff --git a/src/backend/libinput/mod.rs b/src/backend/libinput/mod.rs index 1c16236..cf3d31d 100644 --- a/src/backend/libinput/mod.rs +++ b/src/backend/libinput/mod.rs @@ -427,6 +427,7 @@ impl From for backend::MouseButtonState { #[cfg(feature = "backend_session")] pub struct LibinputSessionInterface(S); +// Session is a trait, so we have to impl Debug manually #[cfg(feature = "backend_session")] impl fmt::Debug for LibinputSessionInterface { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/src/backend/session/dbus/logind.rs b/src/backend/session/dbus/logind.rs index c51a49c..f55fd07 100644 --- a/src/backend/session/dbus/logind.rs +++ b/src/backend/session/dbus/logind.rs @@ -71,6 +71,7 @@ struct LogindSessionImpl { logger: ::slog::Logger, } +// DBusConnection does not implement debug, so we have to impl Debug manually impl fmt::Debug for LogindSessionImpl { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("LogindSessionImpl ") diff --git a/src/backend/udev.rs b/src/backend/udev.rs index 45fe192..2b6cab0 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -63,6 +63,7 @@ pub struct UdevBackend { logger: ::slog::Logger, } +// MonitorSocket does not implement debug, so we have to impl Debug manually impl fmt::Debug for UdevBackend { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use udev::AsRaw; diff --git a/src/backend/winit.rs b/src/backend/winit.rs index 5a501ea..48e5d1c 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -66,6 +66,7 @@ enum Window { }, } +// WlEglSurface does not implement debug, so we have to impl Debug manually impl fmt::Debug for Window { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { diff --git a/src/signaling.rs b/src/signaling.rs index 9a6743d..2e41121 100644 --- a/src/signaling.rs +++ b/src/signaling.rs @@ -111,6 +111,7 @@ struct SignalInner { pending_events: RefCell>, } +// WeakCallback does not implement debug, so we have to impl Debug manually impl fmt::Debug for SignalInner { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SignalInner") diff --git a/src/wayland/compositor/mod.rs b/src/wayland/compositor/mod.rs index 40b5e1b..a1d419c 100644 --- a/src/wayland/compositor/mod.rs +++ b/src/wayland/compositor/mod.rs @@ -172,6 +172,7 @@ pub struct SurfaceAttributes { pub user_data: UserDataMap, } +// UserDataMap does not implement debug, so we have to impl Debug manually impl fmt::Debug for SurfaceAttributes { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SurfaceAttributes") diff --git a/src/wayland/seat/keyboard.rs b/src/wayland/seat/keyboard.rs index 7244f92..8ad7c5f 100644 --- a/src/wayland/seat/keyboard.rs +++ b/src/wayland/seat/keyboard.rs @@ -120,6 +120,7 @@ struct KbdInternal { focus_hook: Box)>, } +// focus_hook does not implement debug, so we have to impl Debug manually impl fmt::Debug for KbdInternal { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("KbdInternal") diff --git a/src/wayland/seat/mod.rs b/src/wayland/seat/mod.rs index 385dca8..9c2c982 100644 --- a/src/wayland/seat/mod.rs +++ b/src/wayland/seat/mod.rs @@ -74,6 +74,7 @@ pub(crate) struct SeatRc { name: String, } +// UserDataMap does not implement debug, so we have to impl Debug manually impl fmt::Debug for SeatRc { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SeatRc") diff --git a/src/wayland/seat/pointer.rs b/src/wayland/seat/pointer.rs index 0933ded..d09837f 100644 --- a/src/wayland/seat/pointer.rs +++ b/src/wayland/seat/pointer.rs @@ -35,6 +35,7 @@ enum GrabStatus { Borrowed, } +// PointerGrab is a trait, so we have to impl Debug manually impl fmt::Debug for GrabStatus { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -55,6 +56,7 @@ struct PointerInternal { image_callback: Box, } +// image_callback does not implement debug, so we have to impl Debug manually impl fmt::Debug for PointerInternal { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Point")