Struct rusb::HotplugBuilder

source ·
pub struct HotplugBuilder { /* private fields */ }
Expand description

Builds hotplug Registration with custom configuration values.

Implementations§

source§

impl HotplugBuilder

source

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.

source

pub fn vendor_id(&mut self, vendor_id: u16) -> &mut Self

Devices can optionally be filtered by vendor

source

pub fn product_id(&mut self, product_id: u16) -> &mut Self

Devices can optionally be filtered by product id

source

pub fn class(&mut self, class: u8) -> &mut Self

Devices can optionally be filtered by class

source

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.

source

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

source§

fn clone(&self) -> HotplugBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for HotplugBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for HotplugBuilder

source§

fn default() -> HotplugBuilder

Returns the “default value” for a type. Read more
source§

impl Copy for HotplugBuilder

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.