Struct rusb::HotplugBuilder [−][src]
pub struct HotplugBuilder { /* fields omitted */ }
Expand description
Builds hotplug Registration with custom configuration values.
Implementations
Returns a new builder with the no filter Devices can optionally be filtered by HotplugBuilder::vendor_id and HotplugBuilder::product_id
Registration is done by by calling register
.
Devices can optionally be filtered by vendor
Devices can optionally be filtered by product id
If enumerate
is true
, then devices that are already
connected will cause your callback’s Hotplug::device_arrived method to be
called for them.
pub fn register<U: UsbContext, T: Borrow<U>>(
self,
context: T,
callback: Box<dyn Hotplug<U>>
) -> Result<Registration<U>>
pub fn register<U: UsbContext, T: Borrow<U>>(
self,
context: T,
callback: Box<dyn Hotplug<U>>
) -> Result<Registration<U>>
Register a callback
to be called on hotplug events. The callback’s
Hotplug::device_arrived method is called when a new device is added to
the bus, and Hotplug::device_left is called when it is removed.
The callback will remain registered until the returned Registration is
dropped, which can be done explicitly with Context::unregister_callback
.
When handling a Hotplug::device_arrived event it is considered safe to call
any rusb
function that takes a Device
. It also safe to open a device and
submit asynchronous transfers.
However, most other functions that take a DeviceHandle
are not safe to call.
Examples of such functions are any of the synchronous API functions or
the blocking functions that retrieve various USB descriptors.
These functions must be used outside of the context of the Hotplug functions.
Trait Implementations
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for HotplugBuilder
impl Send for HotplugBuilder
impl Sync for HotplugBuilder
impl Unpin for HotplugBuilder
impl UnwindSafe for HotplugBuilder
Blanket Implementations
Mutably borrows from an owned value. Read more