pub trait UsbTransfer: Send + Sync {
// Required methods
fn bulk_write(
&self,
endpoint: u8,
data: &[u8],
timeout: Duration,
) -> Result<usize, U3vError>;
fn bulk_read(
&self,
endpoint: u8,
buf: &mut [u8],
timeout: Duration,
) -> Result<usize, U3vError>;
// Provided methods
fn bulk_in(
self: &Arc<Self>,
endpoint: u8,
) -> Result<Box<dyn BulkIn>, U3vError>
where Self: Sized + 'static { ... }
fn max_packet_size(&self, _endpoint: u8) -> Option<usize> { ... }
fn link_speed(&self) -> Option<UsbSpeed> { ... }
fn is_present(&self) -> Option<bool> { ... }
}Expand description
Abstraction over a claimed USB device for bulk endpoint I/O.
Implementations must be safe to share across threads. The control and
stream channels use different endpoints, so a single UsbTransfer can
serve both concurrently (with internal synchronization if needed).
Required Methods§
Provided Methods§
Sourcefn bulk_in(self: &Arc<Self>, endpoint: u8) -> Result<Box<dyn BulkIn>, U3vError>where
Self: Sized + 'static,
fn bulk_in(self: &Arc<Self>, endpoint: u8) -> Result<Box<dyn BulkIn>, U3vError>where
Self: Sized + 'static,
Reads on the bulk IN endpoint that can be queued ahead of the
device, as a stream needs them.
The default reads one transfer at a time through
bulk_read, when the next completion is asked for:
correct, but with nothing queued while the host is busy elsewhere. A
transport that can keep transfers in flight overrides it.
Sourcefn max_packet_size(&self, _endpoint: u8) -> Option<usize>
fn max_packet_size(&self, _endpoint: u8) -> Option<usize>
The largest packet the endpoint carries, from its descriptor; None
when unknown. Every IN transfer a stream asks for is a multiple of
it, so that a packet never straddles two transfers.
Sourcefn link_speed(&self) -> Option<UsbSpeed>
fn link_speed(&self) -> Option<UsbSpeed>
The speed the host’s USB stack reports the device runs at; None
when this transport cannot tell.
Sourcefn is_present(&self) -> Option<bool>
fn is_present(&self) -> Option<bool>
Whether the operating system still lists the device, asked after a
transfer failed in a way that does not say whether it is gone;
None when this transport cannot tell. One look, no waiting.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".