[][src]Struct usb_device::endpoint::Endpoint

pub struct Endpoint<'a, B: UsbBus, D: EndpointDirection> { /* fields omitted */ }

Handle for a USB endpoint. The endpoint direction is constrained by the D type argument, which must be either In or Out.

Methods

impl<B: UsbBus, D: EndpointDirection, '_> Endpoint<'_, B, D>
[src]

pub fn address(&self) -> EndpointAddress
[src]

Gets the endpoint address including direction bit.

pub fn ep_type(&self) -> EndpointType
[src]

Gets the endpoint transfer type.

pub fn max_packet_size(&self) -> u16
[src]

Gets the maximum packet size for the endpoint.

pub fn interval(&self) -> u8
[src]

Gets the poll interval for interrupt endpoints.

pub fn stall(&self)
[src]

Sets the STALL condition for the endpoint.

pub fn unstall(&self)
[src]

Clears the STALL condition of the endpoint.

impl<B: UsbBus, '_> Endpoint<'_, B, In>
[src]

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

Writes a single packet of data to the specified endpoint and returns number of bytes actually written.

The only reason for a short write is if the caller passes a slice larger than the amount of memory allocated earlier, and this is generally an error in the class implementation.

Errors

Note: USB bus implementation errors are directly passed through, so be prepared to handle other errors as well.

impl<B: UsbBus, '_> Endpoint<'_, B, Out>
[src]

pub fn read(&self, data: &mut [u8]) -> Result<usize>
[src]

Reads a single packet of data from the specified endpoint and returns the actual length of the packet.

This should also clear any NAK flags and prepare the endpoint to receive the next packet.

Errors

Note: USB bus implementation errors are directly passed through, so be prepared to handle other errors as well.

  • InvalidEndpoint - The ep_addr does not point to a valid endpoint that was previously allocated with UsbBus::alloc_ep.
  • WouldBlock - There is no packet to be read. Note that this is different from a received zero-length packet, which is valid in USB. A zero-length packet will return Ok(0).
  • BufferOverflow - The received packet is too long to fix in buf. This is generally an error in the class implementation.

Auto Trait Implementations

impl<'a, B, D> Send for Endpoint<'a, B, D> where
    D: Send

impl<'a, B, D> Sync for Endpoint<'a, B, D> where
    D: Sync

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]