Struct rusb::HotplugBuilder
source · pub struct HotplugBuilder { /* private fields */ }
Expand description
Builds hotplug Registration with custom configuration values.
Implementations§
source§impl HotplugBuilder
impl HotplugBuilder
sourcepub fn new() -> Self
pub fn new() -> Self
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
.
sourcepub fn vendor_id(&mut self, vendor_id: u16) -> &mut Self
pub fn vendor_id(&mut self, vendor_id: u16) -> &mut Self
Devices can optionally be filtered by vendor
sourcepub fn product_id(&mut self, product_id: u16) -> &mut Self
pub fn product_id(&mut self, product_id: u16) -> &mut Self
Devices can optionally be filtered by product id
sourcepub fn enumerate(&mut self, enumerate: bool) -> &mut Self
pub fn enumerate(&mut self, enumerate: bool) -> &mut Self
If enumerate
is true
, then devices that are already
connected will cause your callback’s Hotplug::device_arrived method to be
called for them.
sourcepub 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§
source§impl Clone for HotplugBuilder
impl Clone for HotplugBuilder
source§fn clone(&self) -> HotplugBuilder
fn clone(&self) -> HotplugBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more