| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#, Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#}; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::c_voidrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_void#, timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#}; |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 4 | fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#, |
| 5 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, |
| 6 | memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::ManuallyDroprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/manually_drop/ManuallyDrop#, |
| 7 | pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#, |
| 8 | syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::{ |
| 9 | atomicrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/::{AtomicU8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU8#, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#}, |
| 10 | Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#, |
| 11 | }, |
| 12 | }; |
| 13 | |
| 14 | use logrust-analyzer cargo log 0.4.34 crate/::{debugrust-analyzer cargo log 0.4.34 macros/debug!, errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/, warnrust-analyzer cargo log 0.4.34 macros/warn!}; |
| 15 | use rustixrust-analyzer cargo rustix 1.1.4 crate/::eventrust-analyzer cargo rustix 1.1.4 event/::epollrust-analyzer cargo rustix 1.1.4 event/epoll/; |
| 16 | use rustixrust-analyzer cargo rustix 1.1.4 crate/::fdrust-analyzer cargo rustix 1.1.4 fd/::AsFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/AsFd#; |
| 17 | use rustixrust-analyzer cargo rustix 1.1.4 crate/::{ |
| 18 | fdrust-analyzer cargo rustix 1.1.4 fd/::{AsRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd#, FromRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/FromRawFd#, OwnedFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/OwnedFd#}, |
| 19 | fsrust-analyzer cargo rustix 1.1.4 fs/::{Moderust-analyzer cargo rustix 1.1.4 backend/fs/types/Mode#, OFlagsrust-analyzer cargo rustix 1.1.4 backend/fs/types/OFlags#}, |
| 20 | iorust-analyzer cargo rustix 1.1.4 io/::Errnorust-analyzer cargo rustix 1.1.4 backend/io/errno/Errno#, |
| 21 | }; |
| 22 | |
| 23 | use superrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/::{ |
| 24 | errno_to_transfer_errorrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/errno_to_transfer_error()., eventsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/events/, |
| 25 | usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::{selfrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/, Urbrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/Urb#}, |
| 26 | SysfsPathrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/enumeration/SysfsPath#, |
| 27 | }; |
| 28 | use craterust-analyzer cargo nusb 0.1.13 crate/::platformrust-analyzer cargo nusb 0.1.13 platform/::linux_usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/::eventsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/events/::Watchrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/events/Watch#; |
| 29 | use craterust-analyzer cargo nusb 0.1.13 crate/::{ |
| 30 | descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/::{parse_concatenated_config_descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/parse_concatenated_config_descriptors()., Configurationrust-analyzer cargo nusb 0.1.13 descriptors/Configuration#, DESCRIPTOR_LEN_DEVICErust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_LEN_DEVICE.}, |
| 31 | transferrust-analyzer cargo nusb 0.1.13 transfer/::{ |
| 32 | notify_completionrust-analyzer cargo nusb 0.1.13 transfer/internal/notify_completion()., Controlrust-analyzer cargo nusb 0.1.13 transfer/control/Control#, ControlTyperust-analyzer cargo nusb 0.1.13 transfer/control/ControlType#, Directionrust-analyzer cargo nusb 0.1.13 transfer/control/Direction#, EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#, Recipientrust-analyzer cargo nusb 0.1.13 transfer/control/Recipient#, TransferErrorrust-analyzer cargo nusb 0.1.13 transfer/TransferError#, |
| 33 | TransferHandlerust-analyzer cargo nusb 0.1.13 transfer/internal/TransferHandle#, |
| 34 | }, |
| 35 | DeviceInforust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#, Errorrust-analyzer cargo nusb 0.1.13 Error#, |
| 36 | }; |
| 37 | |
| 38 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) struct LinuxDevicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice# { |
| 39 | fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd.: OwnedFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/OwnedFd#, |
| 40 | events_idrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#events_id.: usize, |
| 41 | |
| 42 | /// Read from the fd, consists of device descriptor followed by configuration descriptors |
| 43 | descriptorsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#descriptors.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, |
| 44 | |
| 45 | sysfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#sysfs.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<SysfsPathrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/enumeration/SysfsPath#>, |
| 46 | active_configrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#active_config.: AtomicU8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU8#, |
| 47 | } |
| 48 | |
| 49 | impl LinuxDevicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice# { |
| 50 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn from_device_inforust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]from_device_info().(d: &DeviceInforust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<LinuxDevicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#>, Errorrust-analyzer cargo nusb 0.1.13 Error#> { |
| 51 | let busnum = d.bus_numberrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]bus_number().(); |
| 52 | let devnum = d.device_addressrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]device_address().(); |
| 53 | let active_config = d.pathrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#path..read_attrrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/enumeration/impl#[SysfsPath]read_attr().("bConfigurationValue")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 54 | |
| 55 | let path = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<String>`]from().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("/dev/bus/usb/{busnum:03}/{devnum:03}")); |
| 56 | debugrust-analyzer cargo log 0.4.34 macros/debug!!("Opening usbfs device {}", path.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().()); |
| 57 | let fd = rustixrust-analyzer cargo rustix 1.1.4 crate/::fsrust-analyzer cargo rustix 1.1.4 fs/::openrust-analyzer cargo rustix 1.1.4 fs/abs/open().(path, OFlagsrust-analyzer cargo rustix 1.1.4 backend/fs/types/OFlags#::RDWRrust-analyzer cargo rustix 1.1.4 backend/fs/types/impl#[OFlags]RDWR. rust-analyzer cargo rustix 1.1.4 backend/fs/types/impl#[OFlags][`BitOr<Self>`]bitor().|rust-analyzer cargo rustix 1.1.4 backend/fs/types/impl#[OFlags][`BitOr<Self>`]bitor(). rust-analyzer cargo rustix 1.1.4 backend/fs/types/impl#[OFlags][`BitOr<Self>`]bitor().OFlagsrust-analyzer cargo rustix 1.1.4 backend/fs/types/OFlags#::CLOEXECrust-analyzer cargo rustix 1.1.4 backend/fs/types/impl#[OFlags]CLOEXEC., Moderust-analyzer cargo rustix 1.1.4 backend/fs/types/Mode#::emptyrust-analyzer cargo rustix 1.1.4 backend/fs/types/impl#[Mode]empty().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 58 | |
| 59 | let inner = Selfrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]::create_innerrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]create_inner().(fd, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(d.pathrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#path..clonerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/enumeration/impl#[SysfsPath][Clone]clone().()), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(active_config)); |
| 60 | if inner.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() { |
| 61 | debugrust-analyzer cargo log 0.4.34 macros/debug!!("Opened device bus={busnum} addr={devnum}",); |
| 62 | } |
| 63 | inner |
| 64 | } |
| 65 | |
| 66 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn from_fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]from_fd().(fd: OwnedFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/OwnedFd#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<LinuxDevicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#>, Errorrust-analyzer cargo nusb 0.1.13 Error#> { |
| 67 | debugrust-analyzer cargo log 0.4.34 macros/debug!!("Wrapping fd {} as usbfs device", fd.as_raw_fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/impl#[OwnedFd][AsRawFd]as_raw_fd().()); |
| 68 | |
| 69 | Selfrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]::create_innerrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]create_inner().(fd, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) |
| 70 | } |
| 71 | |
| 72 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn create_innerrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]create_inner().( |
| 73 | fd: OwnedFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/OwnedFd#, |
| 74 | sysfs: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<SysfsPathrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/enumeration/SysfsPath#>, |
| 75 | active_config: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>, |
| 76 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<LinuxDevicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#>, Errorrust-analyzer cargo nusb 0.1.13 Error#> { |
| 77 | let descriptors = { |
| 78 | let mut file = unsafe { ManuallyDroprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/manually_drop/ManuallyDrop#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/manually_drop/impl#[`ManuallyDrop<T>`]new().(Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::from_raw_fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/impl#[`fs::File`][FromRawFd]from_raw_fd().(fd.as_raw_fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/impl#[OwnedFd][AsRawFd]as_raw_fd().())) }; |
| 79 | // NOTE: Seek required on android |
| 80 | file.seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File][Seek]seek().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(0))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 81 | let mut buf = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 82 | file.read_to_endrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File][Read]read_to_end().(&mut buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 83 | buf |
| 84 | }; |
| 85 | |
| 86 | let active_config = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(active_config) = active_config { |
| 87 | active_config |
| 88 | } else { |
| 89 | Selfrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]::get_configrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]get_config().(&descriptors, &fd)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 90 | }; |
| 91 | |
| 92 | // because there's no Arc::try_new_cyclic |
| 93 | let mut events_err = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 94 | let arc = Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::new_cyclicrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new_cyclic().(|weak| { |
| 95 | let res = eventsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/events/::registerrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/events/register().( |
| 96 | fd.as_fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/impl#[OwnedFd][AsFd]as_fd().(), |
| 97 | Watchrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/events/Watch#::Devicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/events/Watch#Device#(weak.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Weak<T, A>`][Clone]clone().()), |
| 98 | epollrust-analyzer cargo rustix 1.1.4 event/epoll/::EventFlagsrust-analyzer cargo rustix 1.1.4 backend/event/epoll/EventFlags#::OUTrust-analyzer cargo rustix 1.1.4 backend/event/epoll/impl#[EventFlags]OUT., |
| 99 | ); |
| 100 | let events_id = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().res.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]as_ref().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(&usize::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]MAX.); |
| 101 | events_err = res.errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]err().(); |
| 102 | if events_err.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 103 | debugrust-analyzer cargo log 0.4.34 macros/debug!!("Opened device fd={} with id {}", fd.as_raw_fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/impl#[OwnedFd][AsRawFd]as_raw_fd().(), events_id,); |
| 104 | } |
| 105 | LinuxDevicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice# { |
| 106 | fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd., |
| 107 | events_idrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#events_id., |
| 108 | descriptorsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#descriptors., |
| 109 | sysfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#sysfs., |
| 110 | active_configrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#active_config.: AtomicU8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU8#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU8]new().(active_config), |
| 111 | } |
| 112 | }); |
| 113 | |
| 114 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(err) = events_err { |
| 115 | errorrust-analyzer cargo log 0.4.34 macros/error!!("Failed to initialize event loop: {err}"); |
| 116 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) |
| 117 | } else { |
| 118 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(arc) |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn handle_eventsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]handle_events().(&self) { |
| 123 | debugrust-analyzer cargo log 0.4.34 macros/debug!!("Handling events for device {}", self.events_idrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#events_id.); |
| 124 | match usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::reap_urb_ndelayrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/reap_urb_ndelay().(&self.fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd.) { |
| 125 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(urb_ptr) => { |
| 126 | let user_data = { |
| 127 | let urb = unsafe { &*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().urb_ptr }; |
| 128 | debugrust-analyzer cargo log 0.4.34 macros/debug!!( |
| 129 | "URB {:?} for ep {:x} completed, status={} actual_length={}", |
| 130 | urb_ptr, urb.endpointrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/Urb#endpoint., urb.statusrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/Urb#status., urb.actual_lengthrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/Urb#actual_length. |
| 131 | ); |
| 132 | urb.usercontextrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/Urb#usercontext. |
| 133 | }; |
| 134 | |
| 135 | // SAFETY: pointer came from submit via kernel an we're now done with it |
| 136 | unsafe { notify_completionrust-analyzer cargo nusb 0.1.13 transfer/internal/notify_completion().::<superrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/::TransferDatarust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/transfer/TransferData#>(user_data) } |
| 137 | } |
| 138 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errnorust-analyzer cargo rustix 1.1.4 backend/io/errno/Errno#::AGAINrust-analyzer cargo rustix 1.1.4 backend/io/errno/impl#[Errno]AGAIN.) => {} |
| 139 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errnorust-analyzer cargo rustix 1.1.4 backend/io/errno/Errno#::NODEVrust-analyzer cargo rustix 1.1.4 backend/io/errno/impl#[Errno]NODEV.) => { |
| 140 | debugrust-analyzer cargo log 0.4.34 macros/debug!!("Device {} disconnected", self.events_idrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#events_id.); |
| 141 | |
| 142 | // epoll returns events continuously on a disconnected device, and REAPURB |
| 143 | // only returns ENODEV after all events are received, so unregister to |
| 144 | // keep the event thread from spinning because we won't receive further events. |
| 145 | // The drop impl will try to unregister again, but that's ok. |
| 146 | eventsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/events/::unregister_fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/events/unregister_fd().(self.fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd..as_fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/impl#[OwnedFd][AsFd]as_fd().()); |
| 147 | } |
| 148 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => { |
| 149 | errorrust-analyzer cargo log 0.4.34 macros/error!!("Unexpected error {e} from REAPURBNDELAY"); |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn configuration_descriptorsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]configuration_descriptors().(&self) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &[u8]> { |
| 155 | parse_concatenated_config_descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/parse_concatenated_config_descriptors().(&self.descriptorsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#descriptors.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().DESCRIPTOR_LEN_DEVICErust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_LEN_DEVICE. as usize..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().) |
| 156 | } |
| 157 | |
| 158 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn active_configuration_valuerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]active_configuration_value().(&self) -> u8 { |
| 159 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(sysfs) = self.sysfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#sysfs..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() { |
| 160 | match sysfs.read_attrrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/enumeration/impl#[SysfsPath]read_attr().("bConfigurationValue") { |
| 161 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v) => { |
| 162 | self.active_configrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#active_config..storerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU8]store().(v, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::SeqCstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#SeqCst#); |
| 163 | return v; |
| 164 | } |
| 165 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => { |
| 166 | errorrust-analyzer cargo log 0.4.34 macros/error!!("Failed to read sysfs bConfigurationValue: {e}, using cached value"); |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | self.active_configrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#active_config..loadrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU8]load().(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::SeqCstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#SeqCst#) |
| 171 | } |
| 172 | |
| 173 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn set_configurationrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]set_configuration().(&self, configuration: u8) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo nusb 0.1.13 Error#> { |
| 174 | usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::set_configurationrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/set_configuration().(&self.fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd., configuration)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 175 | self.active_configrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#active_config..storerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU8]store().(configuration, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::SeqCstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#SeqCst#); |
| 176 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 177 | } |
| 178 | |
| 179 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn resetrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]reset().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo nusb 0.1.13 Error#> { |
| 180 | usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::resetrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/reset().(&self.fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 181 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 182 | } |
| 183 | |
| 184 | /// SAFETY: `data` must be valid for `len` bytes to read or write, depending on `Direction` |
| 185 | unsafe fn control_blockingrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]control_blocking().( |
| 186 | &self, |
| 187 | direction: Directionrust-analyzer cargo nusb 0.1.13 transfer/control/Direction#, |
| 188 | control: Controlrust-analyzer cargo nusb 0.1.13 transfer/control/Control#, |
| 189 | data: *mut u8, |
| 190 | len: usize, |
| 191 | timeout: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, |
| 192 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, TransferErrorrust-analyzer cargo nusb 0.1.13 transfer/TransferError#> { |
| 193 | let r = usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::controlrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/control().( |
| 194 | &self.fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd., |
| 195 | usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::CtrlTransferrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer# { |
| 196 | bRequestTyperust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer#bRequestType.: control.request_typerust-analyzer cargo nusb 0.1.13 transfer/control/impl#[Control]request_type().(direction), |
| 197 | bRequestrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer#bRequest.: control.requestrust-analyzer cargo nusb 0.1.13 transfer/control/Control#request., |
| 198 | wValuerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer#wValue.: control.valuerust-analyzer cargo nusb 0.1.13 transfer/control/Control#value., |
| 199 | wIndexrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer#wIndex.: control.indexrust-analyzer cargo nusb 0.1.13 transfer/control/Control#index., |
| 200 | wLengthrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer#wLength.: len.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("length must fit in u16"), |
| 201 | timeoutrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer#timeout.: timeout |
| 202 | .as_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_millis().() |
| 203 | .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().() |
| 204 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("timeout must fit in u32 ms"), |
| 205 | datarust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer#data.: data as *mut c_voidrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_void#, |
| 206 | }, |
| 207 | ); |
| 208 | |
| 209 | r.map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(errno_to_transfer_errorrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/errno_to_transfer_error().) |
| 210 | } |
| 211 | |
| 212 | pub fn control_in_blockingrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]control_in_blocking().( |
| 213 | &self, |
| 214 | control: Controlrust-analyzer cargo nusb 0.1.13 transfer/control/Control#, |
| 215 | data: &mut [u8], |
| 216 | timeout: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, |
| 217 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, TransferErrorrust-analyzer cargo nusb 0.1.13 transfer/TransferError#> { |
| 218 | unsafe { |
| 219 | self.control_blockingrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]control_blocking().( |
| 220 | Directionrust-analyzer cargo nusb 0.1.13 transfer/control/Direction#::Inrust-analyzer cargo nusb 0.1.13 transfer/control/Direction#In#, |
| 221 | control, |
| 222 | data.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().(), |
| 223 | data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), |
| 224 | timeout, |
| 225 | ) |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | pub fn control_out_blockingrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]control_out_blocking().( |
| 230 | &self, |
| 231 | control: Controlrust-analyzer cargo nusb 0.1.13 transfer/control/Control#, |
| 232 | data: &[u8], |
| 233 | timeout: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, |
| 234 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, TransferErrorrust-analyzer cargo nusb 0.1.13 transfer/TransferError#> { |
| 235 | unsafe { |
| 236 | self.control_blockingrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]control_blocking().( |
| 237 | Directionrust-analyzer cargo nusb 0.1.13 transfer/control/Direction#::Outrust-analyzer cargo nusb 0.1.13 transfer/control/Direction#Out#, |
| 238 | control, |
| 239 | data.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().() as *mut u8, |
| 240 | data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), |
| 241 | timeout, |
| 242 | ) |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn make_control_transferrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]make_control_transfer().(self: &Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]>) -> TransferHandlerust-analyzer cargo nusb 0.1.13 transfer/internal/TransferHandle#<superrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/::TransferDatarust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/transfer/TransferData#> { |
| 247 | TransferHandlerust-analyzer cargo nusb 0.1.13 transfer/internal/TransferHandle#::newrust-analyzer cargo nusb 0.1.13 transfer/internal/impl#[`TransferHandle<P>`]new().(superrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/::TransferDatarust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/transfer/TransferData#::newrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/transfer/impl#[TransferData]new().( |
| 248 | self.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().(), |
| 249 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 250 | 0, |
| 251 | EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#::Controlrust-analyzer cargo nusb 0.1.13 transfer/EndpointType#Control#, |
| 252 | )) |
| 253 | } |
| 254 | |
| 255 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn claim_interfacerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]claim_interface().( |
| 256 | self: &Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]>, |
| 257 | interface_number: u8, |
| 258 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<LinuxInterfacerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#>, Errorrust-analyzer cargo nusb 0.1.13 Error#> { |
| 259 | usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::claim_interfacerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/claim_interface().(&self.fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd., interface_number)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 260 | debugrust-analyzer cargo log 0.4.34 macros/debug!!( |
| 261 | "Claimed interface {interface_number} on device id {dev}", |
| 262 | dev = self.events_idrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#events_id. |
| 263 | ); |
| 264 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(LinuxInterfacerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface# { |
| 265 | devicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#device.: self.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().(), |
| 266 | interface_numberrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#interface_number., |
| 267 | reattachrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#reattach.: false, |
| 268 | })) |
| 269 | } |
| 270 | |
| 271 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn detach_and_claim_interfacerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]detach_and_claim_interface().( |
| 272 | self: &Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]>, |
| 273 | interface_number: u8, |
| 274 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<LinuxInterfacerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#>, Errorrust-analyzer cargo nusb 0.1.13 Error#> { |
| 275 | usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::detach_and_claim_interfacerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/detach_and_claim_interface().(&self.fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd., interface_number)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 276 | debugrust-analyzer cargo log 0.4.34 macros/debug!!( |
| 277 | "Detached and claimed interface {interface_number} on device id {dev}", |
| 278 | dev = self.events_idrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#events_id. |
| 279 | ); |
| 280 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(LinuxInterfacerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface# { |
| 281 | devicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#device.: self.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().(), |
| 282 | interface_numberrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#interface_number., |
| 283 | reattachrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#reattach.: true, |
| 284 | })) |
| 285 | } |
| 286 | |
| 287 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn detach_kernel_driverrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]detach_kernel_driver().( |
| 288 | self: &Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]>, |
| 289 | interface_number: u8, |
| 290 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo nusb 0.1.13 Error#> { |
| 291 | usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::detach_kernel_driverrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/detach_kernel_driver().(&self.fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd., interface_number).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 292 | } |
| 293 | |
| 294 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn attach_kernel_driverrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]attach_kernel_driver().( |
| 295 | self: &Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]>, |
| 296 | interface_number: u8, |
| 297 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo nusb 0.1.13 Error#> { |
| 298 | usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::attach_kernel_driverrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/attach_kernel_driver().(&self.fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd., interface_number).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 299 | } |
| 300 | |
| 301 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) unsafe fn submit_urbrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]submit_urb().(&self, urb: *mut Urbrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/Urb#) { |
| 302 | let ep = unsafe { (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().urb).endpointrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/Urb#endpoint. }; |
| 303 | if let Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) = usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::submit_urbrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/submit_urb().(&self.fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd., urb) { |
| 304 | // SAFETY: Transfer was not submitted. We still own the transfer |
| 305 | // and can write to the URB and complete it in place of the handler. |
| 306 | unsafe { |
| 307 | let user_data = { |
| 308 | let u = &mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().urb; |
| 309 | debugrust-analyzer cargo log 0.4.34 macros/debug!!("Failed to submit URB {urb:?} on ep {ep:x}: {e} {u:?}"); |
| 310 | u.actual_lengthrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/Urb#actual_length. = 0; |
| 311 | u.statusrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/Urb#status. = e.raw_os_errorrust-analyzer cargo rustix 1.1.4 backend/io/errno/impl#[Errno]raw_os_error().(); |
| 312 | u.usercontextrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/Urb#usercontext. |
| 313 | }; |
| 314 | notify_completionrust-analyzer cargo nusb 0.1.13 transfer/internal/notify_completion().::<superrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/::TransferDatarust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/transfer/TransferData#>(user_data) |
| 315 | } |
| 316 | } else { |
| 317 | debugrust-analyzer cargo log 0.4.34 macros/debug!!("Submitted URB {urb:?} on ep {ep:x}"); |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) unsafe fn cancel_urbrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]cancel_urb().(&self, urb: *mut Urbrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/Urb#) { |
| 322 | unsafe { |
| 323 | if let Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) = usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::discard_urbrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/discard_urb().(&self.fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd., urb) { |
| 324 | debugrust-analyzer cargo log 0.4.34 macros/debug!!("Failed to cancel URB {urb:?}: {e}"); |
| 325 | } |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | fn get_configrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]get_config().(descriptors: &[u8], fd: &OwnedFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/OwnedFd#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<u8, Errorrust-analyzer cargo nusb 0.1.13 Error#> { |
| 330 | const REQUEST_GET_CONFIGURATIONrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/REQUEST_GET_CONFIGURATION.: u8 = 0x08; |
| 331 | |
| 332 | let mut dst = [0u8; 1]; |
| 333 | |
| 334 | let control = Controlrust-analyzer cargo nusb 0.1.13 transfer/control/Control# { |
| 335 | control_typerust-analyzer cargo nusb 0.1.13 transfer/control/Control#control_type.: ControlTyperust-analyzer cargo nusb 0.1.13 transfer/control/ControlType#::Standardrust-analyzer cargo nusb 0.1.13 transfer/control/ControlType#Standard#, |
| 336 | recipientrust-analyzer cargo nusb 0.1.13 transfer/control/Control#recipient.: Recipientrust-analyzer cargo nusb 0.1.13 transfer/control/Recipient#::Devicerust-analyzer cargo nusb 0.1.13 transfer/control/Recipient#Device#, |
| 337 | requestrust-analyzer cargo nusb 0.1.13 transfer/control/Control#request.: REQUEST_GET_CONFIGURATIONrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/REQUEST_GET_CONFIGURATION., |
| 338 | valuerust-analyzer cargo nusb 0.1.13 transfer/control/Control#value.: 0, |
| 339 | indexrust-analyzer cargo nusb 0.1.13 transfer/control/Control#index.: 0, |
| 340 | }; |
| 341 | |
| 342 | let r = usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::controlrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/control().( |
| 343 | &fd, |
| 344 | usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::CtrlTransferrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer# { |
| 345 | bRequestTyperust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer#bRequestType.: control.request_typerust-analyzer cargo nusb 0.1.13 transfer/control/impl#[Control]request_type().(Directionrust-analyzer cargo nusb 0.1.13 transfer/control/Direction#::Inrust-analyzer cargo nusb 0.1.13 transfer/control/Direction#In#), |
| 346 | bRequestrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer#bRequest.: control.requestrust-analyzer cargo nusb 0.1.13 transfer/control/Control#request., |
| 347 | wValuerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer#wValue.: control.valuerust-analyzer cargo nusb 0.1.13 transfer/control/Control#value., |
| 348 | wIndexrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer#wIndex.: control.indexrust-analyzer cargo nusb 0.1.13 transfer/control/Control#index., |
| 349 | wLengthrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer#wLength.: dst.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as u16, |
| 350 | timeoutrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer#timeout.: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(50) |
| 351 | .as_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_millis().() |
| 352 | .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().() |
| 353 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("timeout must fit in u32 ms"), |
| 354 | datarust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/CtrlTransfer#data.: &mut dst[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). as *mut u8 as *mut c_voidrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_void#, |
| 355 | }, |
| 356 | ); |
| 357 | |
| 358 | match r { |
| 359 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(n) => { |
| 360 | if n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().dst.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { |
| 361 | let active_config = dst[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().; |
| 362 | debugrust-analyzer cargo log 0.4.34 macros/debug!!("Obtained active configuration for fd {} from GET_CONFIGURATION request: {active_config}", fd.as_raw_fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/impl#[OwnedFd][AsRawFd]as_raw_fd().()); |
| 363 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(active_config); |
| 364 | } else { |
| 365 | warnrust-analyzer cargo log 0.4.34 macros/warn!!("GET_CONFIGURATION request returned incorrect length: {n}, expected 1",); |
| 366 | } |
| 367 | } |
| 368 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => { |
| 369 | warnrust-analyzer cargo log 0.4.34 macros/warn!!( |
| 370 | "GET_CONFIGURATION request failed: {:?}", |
| 371 | errno_to_transfer_errorrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/errno_to_transfer_error().(e) |
| 372 | ); |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | if descriptors.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().DESCRIPTOR_LEN_DEVICErust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_LEN_DEVICE. as usize { |
| 377 | warnrust-analyzer cargo log 0.4.34 macros/warn!!( |
| 378 | "Descriptors for device fd {} too short to use fallback configuration", |
| 379 | fd.as_raw_fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/impl#[OwnedFd][AsRawFd]as_raw_fd().() |
| 380 | ); |
| 381 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::Otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Other#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()); |
| 382 | } |
| 383 | |
| 384 | // Assume the current configuration is the first one |
| 385 | // See: https://github.com/libusb/libusb/blob/467b6a8896daea3d104958bf0887312c5d14d150/libusb/os/linux_usbfs.c#L865 |
| 386 | let mut descriptors = |
| 387 | parse_concatenated_config_descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/parse_concatenated_config_descriptors().(&descriptors[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().DESCRIPTOR_LEN_DEVICErust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_LEN_DEVICE. as usize..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) |
| 388 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(Configurationrust-analyzer cargo nusb 0.1.13 descriptors/Configuration#::newrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]new().); |
| 389 | |
| 390 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config) = descriptors.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().() { |
| 391 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(config.configuration_valuerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]configuration_value().()); |
| 392 | } |
| 393 | |
| 394 | errorrust-analyzer cargo log 0.4.34 macros/error!!( |
| 395 | "No available configurations for device fd {}", |
| 396 | fd.as_raw_fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/impl#[OwnedFd][AsRawFd]as_raw_fd().() |
| 397 | ); |
| 398 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::Otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Other#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | impl Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for LinuxDevicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice# { |
| 403 | fn droprust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice][Drop]drop().(&mut self) { |
| 404 | debugrust-analyzer cargo log 0.4.34 macros/debug!!("Closing device {}", self.events_idrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#events_id.); |
| 405 | eventsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/events/::unregisterrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/events/unregister().(self.fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd..as_fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/impl#[OwnedFd][AsFd]as_fd().(), self.events_idrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#events_id.) |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) struct LinuxInterfacerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface# { |
| 410 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) interface_numberrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#interface_number.: u8, |
| 411 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) devicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#device.: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<LinuxDevicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#>, |
| 412 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) reattachrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#reattach.: bool, |
| 413 | } |
| 414 | |
| 415 | impl LinuxInterfacerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface# { |
| 416 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn make_transferrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxInterface]make_transfer().( |
| 417 | self: &Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Selfrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxInterface]>, |
| 418 | endpoint: u8, |
| 419 | ep_type: EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#, |
| 420 | ) -> TransferHandlerust-analyzer cargo nusb 0.1.13 transfer/internal/TransferHandle#<superrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/::TransferDatarust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/transfer/TransferData#> { |
| 421 | TransferHandlerust-analyzer cargo nusb 0.1.13 transfer/internal/TransferHandle#::newrust-analyzer cargo nusb 0.1.13 transfer/internal/impl#[`TransferHandle<P>`]new().(superrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/::TransferDatarust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/transfer/TransferData#::newrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/transfer/impl#[TransferData]new().( |
| 422 | self.devicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#device..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().(), |
| 423 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().()), |
| 424 | endpoint, |
| 425 | ep_type, |
| 426 | )) |
| 427 | } |
| 428 | |
| 429 | pub fn control_in_blockingrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxInterface]control_in_blocking().( |
| 430 | &self, |
| 431 | control: Controlrust-analyzer cargo nusb 0.1.13 transfer/control/Control#, |
| 432 | data: &mut [u8], |
| 433 | timeout: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, |
| 434 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, TransferErrorrust-analyzer cargo nusb 0.1.13 transfer/TransferError#> { |
| 435 | self.devicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#device..control_in_blockingrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]control_in_blocking().(control, data, timeout) |
| 436 | } |
| 437 | |
| 438 | pub fn control_out_blockingrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxInterface]control_out_blocking().( |
| 439 | &self, |
| 440 | control: Controlrust-analyzer cargo nusb 0.1.13 transfer/control/Control#, |
| 441 | data: &[u8], |
| 442 | timeout: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, |
| 443 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, TransferErrorrust-analyzer cargo nusb 0.1.13 transfer/TransferError#> { |
| 444 | self.devicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#device..control_out_blockingrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxDevice]control_out_blocking().(control, data, timeout) |
| 445 | } |
| 446 | |
| 447 | pub fn set_alt_settingrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxInterface]set_alt_setting().(&self, alt_setting: u8) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo nusb 0.1.13 Error#> { |
| 448 | debugrust-analyzer cargo log 0.4.34 macros/debug!!( |
| 449 | "Set interface {} alt setting to {alt_setting}", |
| 450 | self.interface_numberrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#interface_number. |
| 451 | ); |
| 452 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::set_interfacerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/set_interface().( |
| 453 | &self.devicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#device..fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd., |
| 454 | self.interface_numberrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#interface_number., |
| 455 | alt_setting, |
| 456 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().) |
| 457 | } |
| 458 | |
| 459 | pub fn clear_haltrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxInterface]clear_halt().(&self, endpoint: u8) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo nusb 0.1.13 Error#> { |
| 460 | debugrust-analyzer cargo log 0.4.34 macros/debug!!("Clear halt, endpoint {endpoint:02x}"); |
| 461 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::clear_haltrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/clear_halt().(&self.devicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#device..fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd., endpoint)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().) |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | impl Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for LinuxInterfacerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface# { |
| 466 | fn droprust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/impl#[LinuxInterface][Drop]drop().(&mut self) { |
| 467 | let res = usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::release_interfacerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/release_interface().(&self.devicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#device..fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd., self.interface_numberrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#interface_number.); |
| 468 | debugrust-analyzer cargo log 0.4.34 macros/debug!!( |
| 469 | "Released interface {} on device {}: {res:?}", |
| 470 | self.interface_numberrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#interface_number., self.devicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#device..events_idrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#events_id. |
| 471 | ); |
| 472 | |
| 473 | if res.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() && self.reattachrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#reattach. { |
| 474 | let res = usbfsrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/::attach_kernel_driverrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/usbfs/attach_kernel_driver().(&self.devicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#device..fdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#fd., self.interface_numberrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#interface_number.); |
| 475 | debugrust-analyzer cargo log 0.4.34 macros/debug!!( |
| 476 | "Reattached kernel drivers for interface {} on device {}: {res:?}", |
| 477 | self.interface_numberrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#interface_number., self.devicerust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxInterface#device..events_idrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/device/LinuxDevice#events_id. |
| 478 | ); |
| 479 | } |
| 480 | } |
| 481 | } |