embassy-usb

Crates

git

Versions

default

Flavors

embassy_usb::class::hid

Struct HidReaderWriter

Source
pub struct HidReaderWriter<'d, D: Driver<'d>, const READ_N: usize, const WRITE_N: usize> { /* private fields */ }
Expand description

USB HID reader/writer.

Implementations§

Source§

impl<'d, D: Driver<'d>, const READ_N: usize, const WRITE_N: usize> HidReaderWriter<'d, D, READ_N, WRITE_N>

Source

pub fn new( builder: &mut Builder<'d, D>, state: &'d mut State<'d>, config: Config<'d>, ) -> Self

Creates a new HidReaderWriter.

This will allocate one IN and one OUT endpoints. If you only need writing (sending) HID reports, consider using HidWriter::new instead, which allocates an IN endpoint only.

Source

pub fn split(self) -> (HidReader<'d, D, READ_N>, HidWriter<'d, D, WRITE_N>)

Splits into separate readers/writers for input and output reports.

Source

pub async fn ready(&mut self)

Waits for both IN and OUT endpoints to be enabled.

Source

pub async fn write_serialize<IR: AsInputReport>( &mut self, r: &IR, ) -> Result<(), EndpointError>

Writes an input report by serializing the given report structure.

Source

pub async fn write(&mut self, report: &[u8]) -> Result<(), EndpointError>

Writes report to its interrupt endpoint.

Source

pub async fn read(&mut self, buf: &mut [u8]) -> Result<usize, ReadError>

Reads an output report from the Interrupt Out pipe.

See HidReader::read.

Auto Trait Implementations§

§

impl<'d, D, const READ_N: usize, const WRITE_N: usize> Freeze for HidReaderWriter<'d, D, READ_N, WRITE_N>
where <D as Driver<'d>>::EndpointOut: Freeze, <D as Driver<'d>>::EndpointIn: Freeze,

§

impl<'d, D, const READ_N: usize, const WRITE_N: usize> RefUnwindSafe for HidReaderWriter<'d, D, READ_N, WRITE_N>

§

impl<'d, D, const READ_N: usize, const WRITE_N: usize> Send for HidReaderWriter<'d, D, READ_N, WRITE_N>
where <D as Driver<'d>>::EndpointOut: Send, <D as Driver<'d>>::EndpointIn: Send,

§

impl<'d, D, const READ_N: usize, const WRITE_N: usize> Sync for HidReaderWriter<'d, D, READ_N, WRITE_N>
where <D as Driver<'d>>::EndpointOut: Sync, <D as Driver<'d>>::EndpointIn: Sync,

§

impl<'d, D, const READ_N: usize, const WRITE_N: usize> Unpin for HidReaderWriter<'d, D, READ_N, WRITE_N>
where <D as Driver<'d>>::EndpointOut: Unpin, <D as Driver<'d>>::EndpointIn: Unpin,

§

impl<'d, D, const READ_N: usize, const WRITE_N: usize> UnwindSafe for HidReaderWriter<'d, D, READ_N, WRITE_N>
where <D as Driver<'d>>::EndpointOut: UnwindSafe, <D as Driver<'d>>::EndpointIn: UnwindSafe,

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.