| 1 | mod transfer; |
| 2 | use rustix::io::Errno; |
| 3 | pub(crate) use transfer::TransferData; |
| 4 | mod usbfs; |
| 5 | |
| 6 | mod enumeration; |
| 7 | mod events; |
| 8 | pub use enumeration::{list_devices, SysfsPath}; |
| 9 | |
| 10 | mod device; |
| 11 | pub(crate) use device::LinuxDevice as Device; |
| 12 | pub(crate) use device::LinuxInterface as Interface; |
| 13 | |
| 14 | mod hotplug; |
| 15 | pub(crate) use hotplug::LinuxHotplugWatch as HotplugWatch; |
| 16 | |
| 17 | use crate::transfer::TransferError; |
| 18 | |
| 19 | #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] |
| 20 | pub struct DeviceId { |
| 21 | pub(crate) bus: u8, |
| 22 | pub(crate) addr: u8, |
| 23 | } |
| 24 | |
| 25 | fn errno_to_transfer_error(e: Errno) -> TransferError { |
| 26 | match e { |
| 27 | Errno::NODEV | Errno::SHUTDOWN => TransferError::Disconnected, |
| 28 | Errno::PIPE => TransferError::Stall, |
| 29 | Errno::NOENT | Errno::CONNRESET | Errno::TIMEDOUT => TransferError::Cancelled, |
| 30 | Errno::PROTO | Errno::ILSEQ | Errno::OVERFLOW | Errno::COMM | Errno::TIME => { |
| 31 | TransferError::Fault |
| 32 | } |
| 33 | _ => TransferError::Unknown, |
| 34 | } |
| 35 | } |