Skip to main content

UsbDevice

Struct UsbDevice 

Source
pub struct UsbDevice<'a, B: UsbBus> { /* private fields */ }
Expand description

USB composite device.

Ties together the bus driver, a control-transfer state machine, and one or more UsbClass implementations.

The lifetime 'a is the lifetime of the UsbBusAllocator from which this device and all classes were built.

Implementations§

Source§

impl<'a, B: UsbBus> UsbDevice<'a, B>

Source

pub fn state(&self) -> DeviceState

Current device state.

Source

pub fn is_configured(&self) -> bool

true if the device is fully configured.

Source

pub fn bus(&self) -> &B

Borrow the underlying bus (for platform-specific calls).

Source

pub fn remote_wakeup_enabled(&self) -> bool

Whether host remote wake-up is currently enabled.

Source

pub fn set_self_powered(&mut self, is_self_powered: bool)

Override the self-powered flag at runtime.

Source

pub fn force_reset(&mut self) -> UsbResult<()>

Force a USB disconnect + re-enumeration (not supported on all buses).

Source

pub fn poll(&mut self, classes: &mut [&'_ mut dyn UsbClass<B>]) -> bool

Poll the bus for events and dispatch them to classes.

Returns true if any class may have pending data to read or write.

Call this at least once every 10 ms while connected.

Auto Trait Implementations§

§

impl<'a, B> Forget for UsbDevice<'a, B>

§

impl<'a, B> Freeze for UsbDevice<'a, B>
where &'a B: Freeze,

§

impl<'a, B> Move for UsbDevice<'a, B>

§

impl<'a, B> RefUnwindSafe for UsbDevice<'a, B>

§

impl<'a, B> Send for UsbDevice<'a, B>
where &'a B: Send,

§

impl<'a, B> Sync for UsbDevice<'a, B>
where &'a B: Sync,

§

impl<'a, B> Unpin for UsbDevice<'a, B>
where &'a B: Unpin,

§

impl<'a, B> UnsafeUnpin for UsbDevice<'a, B>

§

impl<'a, B> UnwindSafe for UsbDevice<'a, B>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.