| 1 | //! Types for receiving notifications when USB devices are connected or |
| 2 | //! disconnected from the system. |
| 3 | //! |
| 4 | //! See [`super::watch_devices`] for a usage example. |
| 5 | |
| 6 | use futures_corerust-analyzer cargo futures-core 0.3.31 crate/::Streamrust-analyzer cargo futures-core 0.3.31 stream/Stream#; |
| 7 | |
| 8 | use craterust-analyzer cargo nusb 0.1.13 crate/::{DeviceIdrust-analyzer cargo nusb 0.1.13 enumeration/DeviceId#, DeviceInforust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#}; |
| 9 | |
| 10 | /// Stream of device connection / disconnection events. |
| 11 | /// |
| 12 | /// Call [`super::watch_devices`] to begin watching device |
| 13 | /// events and create a `HotplugWatch`. |
| 14 | pub struct HotplugWatchrust-analyzer cargo nusb 0.1.13 hotplug/HotplugWatch#(pub(craterust-analyzer cargo nusb 0.1.13 crate/) craterust-analyzer cargo nusb 0.1.13 crate/::platformrust-analyzer cargo nusb 0.1.13 platform/::HotplugWatchrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/hotplug/LinuxHotplugWatch#); |
| 15 | |
| 16 | impl Streamrust-analyzer cargo futures-core 0.3.31 stream/Stream# for HotplugWatchrust-analyzer cargo nusb 0.1.13 hotplug/HotplugWatch# { |
| 17 | type Itemrust-analyzer cargo nusb 0.1.13 hotplug/impl#[HotplugWatch][Stream]Item# = HotplugEventrust-analyzer cargo nusb 0.1.13 hotplug/HotplugEvent#; |
| 18 | |
| 19 | fn poll_nextrust-analyzer cargo nusb 0.1.13 hotplug/impl#[HotplugWatch][Stream]poll_next().( |
| 20 | mut self: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/::Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo nusb 0.1.13 hotplug/impl#[HotplugWatch][Stream]>, |
| 21 | cx: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::taskrust-analyzer cargo std https://github.com/rust-lang/rust/library/std task/::Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>, |
| 22 | ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::taskrust-analyzer cargo std https://github.com/rust-lang/rust/library/std task/::Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo nusb 0.1.13 hotplug/impl#[HotplugWatch][Stream]::Itemrust-analyzer cargo futures-core 0.3.31 stream/Stream#Item#>> { |
| 23 | self.0rust-analyzer cargo nusb 0.1.13 hotplug/HotplugWatch#0..poll_nextrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/hotplug/impl#[LinuxHotplugWatch]poll_next().(cx).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/impl#[`Poll<T>`]map().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#) |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | /// Event returned from the [`HotplugWatch`] stream. |
| 28 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 29 | pub enum HotplugEventrust-analyzer cargo nusb 0.1.13 hotplug/HotplugEvent# { |
| 30 | /// A device has been connected. |
| 31 | Connectedrust-analyzer cargo nusb 0.1.13 hotplug/HotplugEvent#Connected#(DeviceInforust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#), |
| 32 | |
| 33 | /// A device has been disconnected. |
| 34 | Disconnectedrust-analyzer cargo nusb 0.1.13 hotplug/HotplugEvent#Disconnected#(DeviceIdrust-analyzer cargo nusb 0.1.13 enumeration/DeviceId#), |
| 35 | } |
| 36 | |
| 37 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 38 | fn assert_send_syncrust-analyzer cargo nusb 0.1.13 hotplug/assert_send_sync().() { |
| 39 | fn require_send_syncrust-analyzer cargo nusb 0.1.13 hotplug/require_send_sync().<T: Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#>() {} |
| 40 | require_send_syncrust-analyzer cargo nusb 0.1.13 hotplug/require_send_sync().::<HotplugWatchrust-analyzer cargo nusb 0.1.13 hotplug/HotplugWatch#>(); |
| 41 | } |