Skip to main content

Endpoint

Struct Endpoint 

Source
pub struct Endpoint<'a, B: UsbBus, D: EndpointDir> { /* private fields */ }
Expand description

A handle to a specific USB endpoint.

The lifetime 'a is tied to the crate::device::bus::UsbBusAllocator that produced this handle, ensuring the underlying bus cannot be dropped or moved while the handle is alive.

Use the type aliases EndpointIn and EndpointOut for convenience.

Implementations§

Source§

impl<'a, B: UsbBus, D: EndpointDir> Endpoint<'a, B, D>

Source

pub fn address(&self) -> EndpointAddress

Endpoint address (number + direction).

Source

pub fn ep_type(&self) -> EndpointType

Transfer type of this endpoint.

Source

pub fn max_packet_size(&self) -> u16

Maximum packet size in bytes.

Source

pub fn interval(&self) -> u8

Polling interval for interrupt / isochronous endpoints.

Source

pub fn stall(&self)

Stall this endpoint.

Source

pub fn unstall(&self)

Clear the stall condition on this endpoint.

Source§

impl<B: UsbBus> Endpoint<'_, B, In>

Source

pub fn write(&self, data: &[u8]) -> UsbResult<usize>

Write a single packet to this endpoint.

Returns the number of bytes actually written. If the USB peripheral’s transmit buffer is still occupied, returns UsbError::WouldBlock.

Source§

impl<B: UsbBus> Endpoint<'_, B, Out>

Source

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

Read a single packet from this endpoint into buf.

Returns the number of bytes read. Returns UsbError::WouldBlock when no packet is available.

Trait Implementations§

Source§

impl<B: UsbBus + Send, D: EndpointDir> Send for Endpoint<'_, B, D>

Source§

impl<B: UsbBus + Sync, D: EndpointDir> Sync for Endpoint<'_, B, D>

Auto Trait Implementations§

§

impl<'a, B, D> Forget for Endpoint<'a, B, D>

§

impl<'a, B, D> Freeze for Endpoint<'a, B, D>
where &'a B: Freeze, PhantomData<fn() -> D>: Freeze,

§

impl<'a, B, D> Move for Endpoint<'a, B, D>

§

impl<'a, B, D> RefUnwindSafe for Endpoint<'a, B, D>

§

impl<'a, B, D> Unpin for Endpoint<'a, B, D>
where &'a B: Unpin, PhantomData<fn() -> D>: Unpin,

§

impl<'a, B, D> UnsafeUnpin for Endpoint<'a, B, D>

§

impl<'a, B, D> UnwindSafe for Endpoint<'a, B, D>

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.