//! libudev hotplug monitor for the `usb` and `typec` subsystems.
//!//! Wraps the `udev` crate's `MonitorSocket`. The CLI polls the raw fd and
//! drains events via `drain()` whenever the socket is readable.
usestd::io;usestd::os::fd::{AsRawFd, RawFd};useudev::MonitorBuilder;pubstructUdevMonitor{socket:udev::MonitorSocket,
}implUdevMonitor{pubfnnew()->io::Result<Self>{let socket =MonitorBuilder::new()?.match_subsystem("usb")?.match_subsystem("typec")?.listen()?;Ok(UdevMonitor { socket })}pubfnfd(&self)-> RawFd{self.socket.as_raw_fd()}/// Consume any pending events. Returns the number drained — useful as a
/// "did anything actually change?" signal, though we still re-enumerate
/// from sysfs after any non-zero drain.
pubfndrain(&mutself)->usize{self.socket.iter().count()}}