[][src]Struct usb_device::device::UsbDevice

pub struct UsbDevice<'a, B: UsbBus> { /* fields omitted */ }

A USB device consisting of one or more device classes.

Methods

impl<B: UsbBus, '_> UsbDevice<'_, B>
[src]

pub fn state(&self) -> UsbDeviceState
[src]

Gets the current state of the device.

In general class traffic is only possible in the Configured state.

pub fn remote_wakeup_enabled(&self) -> bool
[src]

Gets whether host remote wakeup has been enabled by the host.

pub fn self_powered(&self) -> bool
[src]

Gets whether the device is currently self powered.

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

Sets whether the device is currently self powered.

pub fn force_reset(&mut self) -> Result<()>
[src]

Forces a reset on the UsbBus.

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

Polls the UsbBus for new events and dispatches them to the provided classes. Returns true if one of the classes may have data available for reading or be ready for writing, false otherwise. This should be called periodically as often as possible for the best data rate, or preferably from an interrupt handler. Must be called at least one every 10 milliseconds while connected to the USB host to be USB compliant.

Note: The list of classes passed in must be the same for every call while the device is configured, or the device may enumerate incorrectly or otherwise misbehave. The easiest way to do this is to call the poll method in only one place in your code, as follows:

This example is not tested
usb_dev.poll(&mut [&mut class1, &mut class2]);

Strictly speaking the list of classes is allowed to change between polls if the device has been reset, which is indicated by state being equal to UsbDeviceState::Default, but this is likely to cause compatibility problems with some operating systems.

Auto Trait Implementations

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

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

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]