pub trait EndpointOut: Endpoint {
// Required method
async fn read_transfer(
&mut self,
buf: &mut [u8],
) -> Result<usize, EndpointError>;
}Expand description
OUT Endpoint trait.
Required Methods§
Sourceasync fn read_transfer(
&mut self,
buf: &mut [u8],
) -> Result<usize, EndpointError>
async fn read_transfer( &mut self, buf: &mut [u8], ) -> Result<usize, EndpointError>
Read a transfer from the host into buf, returning the number of bytes received.
What makes up a transfer depends on the endpoint type, see below.
This should also clear any NAK flags and prepare the endpoint to receive the next packet or data block.
§Bulk and interrupt endpoints
Receives packets until either:
bufis full, or- the host sends a packet shorter than
max_packet_size, including a zero-length packet.
§Isochronous endpoints
Receives the data the host sends in one service interval. Data from different service intervals is never merged into one read.
The data of a service interval is at most:
- full speed:
max_packet_size - high speed:
max_packet_size * (additional_transactions + 1) - SuperSpeed:
bytes_per_interval
Isochronous data is not retried: data that is lost on the bus, or that arrives while no read is in progress, may be missing without an error. The host may also skip a service interval without sending anything.
§Errors
EndpointError::Disabled- The endpoint is disabled.EndpointError::BufferOverflow- The received data does not fit inbuf:- bulk and interrupt: a packet is larger than the remaining space in
buf. This can happen ifbuf.len()is:- smaller than
max_packet_size, or - not a multiple of
max_packet_size.
- smaller than
- isochronous: a service interval’s data is larger than
buf.
- bulk and interrupt: a packet is larger than the remaining space in
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".