diff --git a/src/lib.rs b/src/lib.rs index bd03532..8eba029 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +#![warn(missing_debug_implementations)] + use std::collections::HashMap; use std::os::unix::io::{AsRawFd, RawFd}; @@ -11,6 +13,7 @@ fn errno() -> i32 { unsafe { *libc::__errno_location() } } +#[derive(Debug)] pub struct BufferedEventManager { event_manager: EventManager, // TODO The length is always unused, a custom type could thus save `size_of::()` bytes. @@ -91,6 +94,22 @@ pub struct EventManager { events: HashMap, } +impl std::fmt::Debug for EventManager { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("EventManager") + .field("epfd", &self.epfd) + .field( + "events", + &self + .events + .iter() + .map(|(k, v)| (*k, v as *const _ as usize)) + .collect::>(), + ) + .finish() + } +} + impl EventManager { /// Add an entry to the interest list of the epoll file descriptor. ///