Embassy
embassy-usb

Crates

git

Versions

default

Flavors

Struct embassy_usb::class::hid::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>,

§

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

§

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.