Skip to main content

Device

Struct Device 

Source
pub struct Device<'a, C: HostController> { /* private fields */ }
Expand description

An enumerated device.

Implementations§

Source§

impl<'a, C: HostController> Device<'a, C>

Source

pub fn address(&self) -> DeviceAddress

The address the device answers to.

Source

pub fn speed(&self) -> Speed

The speed the device negotiated.

Source

pub fn route(&self) -> Option<HubRoute>

Where the device sits below the root port.

Source

pub fn descriptor(&self) -> &DeviceDescriptor

The device descriptor read while enumerating.

Source

pub fn configuration(&self) -> Configuration<'_>

The configuration descriptor together with its interface and endpoint descriptors.

Source

pub fn control(&self, request: &Request, buffer: &mut [u8]) -> HostResult<usize>

Run one control transfer.

buffer must hold request.length bytes. The returned count is the number of bytes the device actually sent, which may be less than requested.

Source

pub fn set_configuration(&self, value: u8) -> HostResult<()>

Select a configuration.

The endpoints of the device are only usable after this request succeeded.

Source

pub fn read_string(&self, index: u8, out: &mut [u8]) -> HostResult<usize>

Read a string descriptor and convert it to UTF-8.

Returns the number of bytes written to out. Strings longer than thirty-two characters and output that does not fit are truncated at a character boundary.

Source

pub fn open(&self, endpoint: &EndpointDescriptor) -> HostResult<Pipe<'a, C>>

Open the endpoint described by endpoint.

Source

pub fn clear_halt(&self, pipe: &Pipe<'a, C>) -> HostResult<()>

Clear the halt condition of pipe and restart its data toggle.

Called after a transfer failed with HostError::Stall.

Trait Implementations§

Source§

impl<C: HostController> Drop for Device<'_, C>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a, C> Forget for Device<'a, C>

§

impl<'a, C> Freeze for Device<'a, C>
where &'a C: Freeze,

§

impl<'a, C> Move for Device<'a, C>

§

impl<'a, C> RefUnwindSafe for Device<'a, C>

§

impl<'a, C> Send for Device<'a, C>
where &'a C: Send,

§

impl<'a, C> Sync for Device<'a, C>
where &'a C: Sync,

§

impl<'a, C> Unpin for Device<'a, C>
where &'a C: Unpin,

§

impl<'a, C> UnsafeUnpin for Device<'a, C>

§

impl<'a, C> UnwindSafe for Device<'a, C>

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.