pub trait EndpointIn: Endpoint {
// Required method
async fn write_transfer(
&mut self,
buf: &[u8],
needs_zlp: bool,
) -> Result<(), EndpointError>;
}Expand description
IN Endpoint trait.
Required Methods§
Sourceasync fn write_transfer(
&mut self,
buf: &[u8],
needs_zlp: bool,
) -> Result<(), EndpointError>
async fn write_transfer( &mut self, buf: &[u8], needs_zlp: bool, ) -> Result<(), EndpointError>
Write all the data from buf to the endpoint as a transfer.
What makes up a transfer depends on the endpoint type, see below.
When this returns is implementation-defined, for all endpoint types. Drivers may either:
- queue the data and return immediately, or
- wait until the host has collected it.
§Bulk and interrupt endpoints
The driver splits buf into packets of max_packet_size bytes, the last one possibly
shorter, and sends them. A zero-length packet (ZLP) is sent:
- after the data, to end the transfer, if
needs_zlpis true andbuf.len()is an exact non-zero multiple ofmax_packet_size. - alone, if
bufis empty.
§Isochronous endpoints
buf is the data to send in a single service interval. An
empty buf is sent as a zero-length packet. needs_zlp is ignored.
buf.len() must be at most the following, or this fails with
EndpointError::BufferOverflow without sending anything:
- full speed:
max_packet_size - high speed:
max_packet_size * (additional_transactions + 1) - SuperSpeed:
bytes_per_interval
The data goes out when the host next polls the endpoint, which it does once per service interval. The driver offers it for at least one full service interval. If the host still hasn’t collected it after that, what happens is implementation-defined. The driver may:
- keep offering it, so it’s sent late, at a later poll, or
- drop it, without an error.
In a service interval with no data written, what the driver sends is implementation-defined. It may send either:
- a zero-length packet, or
- no answer, which the host will see as an error.
§Errors
EndpointError::Disabled- The endpoint is disabled.EndpointError::BufferOverflow- Isochronous endpoints only:bufis longer than a service interval’s data. Bulk and interrupt endpoints never return this.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".