pub struct LinuxUsbWatcher { /* private fields */ }Expand description
Linux-specific USB device watcher implementation.
This watcher uses the Linux sysfs filesystem (/sys/bus/usb/devices) to monitor
USB device connections and disconnections. It polls the filesystem periodically
to detect changes and sends events through the provided channel.
Device handles are provided for each detected device, including sysfs path.
Future versions may detect device nodes (e.g., /dev/ttyUSB0).
Implementations§
Source§impl LinuxUsbWatcher
impl LinuxUsbWatcher
Sourcepub fn new(tx: Sender<UsbDeviceInfo>) -> Self
pub fn new(tx: Sender<UsbDeviceInfo>) -> Self
Sourcepub async fn start_monitoring(&self) -> Result<(), String>
pub async fn start_monitoring(&self) -> Result<(), String>
Starts monitoring USB devices on Linux.
This method continuously polls the /sys/bus/usb/devices directory
to detect USB device connection and disconnection events. It maintains
a map of known devices and compares against current devices to identify
changes.
§Returns
Returns Ok(()) if monitoring stops gracefully, or Err(String) if
an error occurs during monitoring.
§Errors
Returns an error if:
- The USB devices directory is not accessible
- File system operations fail
- Device information parsing fails