Struct rusb::HotplugBuilder
source · [−]pub struct HotplugBuilder { /* private fields */ }
Expand description
Builds hotplug Registration with custom configuration values.
Implementations
sourceimpl 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
sourceimpl Clone for HotplugBuilder
impl Clone for HotplugBuilder
sourcefn clone(&self) -> HotplugBuilder
fn clone(&self) -> HotplugBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for HotplugBuilder
impl Debug for HotplugBuilder
sourceimpl Default for HotplugBuilder
impl Default for HotplugBuilder
sourcefn default() -> HotplugBuilder
fn default() -> HotplugBuilder
Returns the “default value” for a type. Read more
impl Copy for HotplugBuilder
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more