Struct OpenUsbDevice

Source
pub struct OpenUsbDevice { /* private fields */ }
Expand description

An opened USB device.

Dropping this causes the USB device to be closed.

Implementations§

Source§

impl OpenUsbDevice

Source

pub fn device(&self) -> &UsbDevice

The USB device.

Source

pub async fn close(self) -> Result<()>

Releases all open interfaces and ends the device session.

It is not necessary to call this method, since dropping OpenUsbDevice will also close the USB device.

Source

pub async fn reset(&self) -> Result<()>

Resets the device and cancels all pending operations.

Source

pub async fn select_configuration(&self, configuration: u8) -> Result<()>

Selects the USB device configuration with the specified index.

Source

pub async fn claim_interface(&self, interface: u8) -> Result<()>

Claim specified interface for exclusive access.

Source

pub async fn release_interface(&self, interface: u8) -> Result<()>

Release specified interface from exclusive access.

Source

pub async fn select_alternate_interface( &self, interface: u8, alternate: u8, ) -> Result<()>

Selects the alternate setting with the specified index for an interface.

Source

pub async fn clear_halt( &self, direction: UsbDirection, endpoint: u8, ) -> Result<()>

Clears a halt condition.

A halt condition is when a data transfer to or from the device has a status of ‘stall’, which requires the web page (the host system, in USB terminology) to clear that condition.

Source

pub async fn control_transfer_in( &self, control_request: &UsbControlRequest, len: u16, ) -> Result<Vec<u8>>

Perform a control transfer from device to host.

Source

pub async fn control_transfer_out( &self, control_request: &UsbControlRequest, data: &[u8], ) -> Result<u32>

Perform a control transfer from host to device.

Source

pub async fn isochronous_transfer_in( &self, endpoint: u8, packet_lens: impl IntoIterator<Item = u32>, ) -> Result<Vec<Result<Vec<u8>>>>

Transmits time sensitive information from the device.

Source

pub async fn isochronous_transfer_out( &self, endpoint: u8, packets: impl IntoIterator<Item = &[u8]>, ) -> Result<Vec<Result<u32>>>

Transmits time sensitive information to the device.

Returns the number of bytes sent of each packet.

Source

pub async fn transfer_in(&self, endpoint: u8, len: u32) -> Result<Vec<u8>>

Performs a bulk or interrupt transfer from specified endpoint of the device.

Source

pub async fn transfer_out(&self, endpoint: u8, data: &[u8]) -> Result<u32>

Performs a bulk or interrupt transfer to the specified endpoint of the device.

Returns the number of bytes sent.

Trait Implementations§

Source§

impl AsRef<UsbDevice> for OpenUsbDevice

Source§

fn as_ref(&self) -> &UsbDevice

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for OpenUsbDevice

Source§

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

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

impl Drop for OpenUsbDevice

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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

Source§

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>,

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.