pub trait Driver<'a> {
type EndpointOut: EndpointOut + 'a;
type EndpointIn: EndpointIn + 'a;
type ControlPipe: ControlPipe + 'a;
type Bus: Bus + 'a;
// Required methods
fn alloc_endpoint_out(
&mut self,
ep_type: EndpointType,
ep_addr: Option<EndpointAddress>,
max_packet_size: u16,
interval_ms: u8,
) -> Result<Self::EndpointOut, EndpointAllocError>;
fn alloc_endpoint_in(
&mut self,
ep_type: EndpointType,
ep_addr: Option<EndpointAddress>,
max_packet_size: u16,
interval_ms: u8,
) -> Result<Self::EndpointIn, EndpointAllocError>;
fn start(
self,
control_max_packet_size: u16,
) -> (Self::Bus, Self::ControlPipe);
// Provided methods
fn alloc_endpoint_bulk_out_double_buffered(
&mut self,
ep_addr: Option<EndpointAddress>,
max_packet_size: u16,
) -> Result<Self::EndpointOut, EndpointAllocError> { ... }
fn alloc_endpoint_bulk_in_double_buffered(
&mut self,
ep_addr: Option<EndpointAddress>,
max_packet_size: u16,
) -> Result<Self::EndpointIn, EndpointAllocError> { ... }
}Expand description
Main USB device driver trait.
Implement this to add support for a new hardware platform.
Required Associated Types§
Sourcetype EndpointOut: EndpointOut + 'a
type EndpointOut: EndpointOut + 'a
Type of the OUT endpoints for this driver.
Sourcetype EndpointIn: EndpointIn + 'a
type EndpointIn: EndpointIn + 'a
Type of the IN endpoints for this driver.
Sourcetype ControlPipe: ControlPipe + 'a
type ControlPipe: ControlPipe + 'a
Type of the control pipe for this driver.
Required Methods§
Sourcefn alloc_endpoint_out(
&mut self,
ep_type: EndpointType,
ep_addr: Option<EndpointAddress>,
max_packet_size: u16,
interval_ms: u8,
) -> Result<Self::EndpointOut, EndpointAllocError>
fn alloc_endpoint_out( &mut self, ep_type: EndpointType, ep_addr: Option<EndpointAddress>, max_packet_size: u16, interval_ms: u8, ) -> Result<Self::EndpointOut, EndpointAllocError>
Sourcefn alloc_endpoint_in(
&mut self,
ep_type: EndpointType,
ep_addr: Option<EndpointAddress>,
max_packet_size: u16,
interval_ms: u8,
) -> Result<Self::EndpointIn, EndpointAllocError>
fn alloc_endpoint_in( &mut self, ep_type: EndpointType, ep_addr: Option<EndpointAddress>, max_packet_size: u16, interval_ms: u8, ) -> Result<Self::EndpointIn, EndpointAllocError>
Sourcefn start(self, control_max_packet_size: u16) -> (Self::Bus, Self::ControlPipe)
fn start(self, control_max_packet_size: u16) -> (Self::Bus, Self::ControlPipe)
Start operation of the USB device.
This returns the Bus and ControlPipe instances that are used to operate
the USB device. Additionally, this makes all the previously allocated endpoints
start operating.
This consumes the Driver instance, so it’s no longer possible to allocate more
endpoints.
Provided Methods§
Sourcefn alloc_endpoint_bulk_out_double_buffered(
&mut self,
ep_addr: Option<EndpointAddress>,
max_packet_size: u16,
) -> Result<Self::EndpointOut, EndpointAllocError>
fn alloc_endpoint_bulk_out_double_buffered( &mut self, ep_addr: Option<EndpointAddress>, max_packet_size: u16, ) -> Result<Self::EndpointOut, EndpointAllocError>
Allocates a double-buffered bulk OUT endpoint.
With double buffering the hardware can receive the next packet while the previous one is still being read, which improves throughput. It may use more hardware resources than an ordinary endpoint, such as twice the packet memory or the endpoint number in both directions.
Drivers that don’t support double buffering allocate an ordinary bulk endpoint, which is what the default implementation does.
Sourcefn alloc_endpoint_bulk_in_double_buffered(
&mut self,
ep_addr: Option<EndpointAddress>,
max_packet_size: u16,
) -> Result<Self::EndpointIn, EndpointAllocError>
fn alloc_endpoint_bulk_in_double_buffered( &mut self, ep_addr: Option<EndpointAddress>, max_packet_size: u16, ) -> Result<Self::EndpointIn, EndpointAllocError>
Allocates a double-buffered bulk IN endpoint.
With double buffering the next packet can be queued while the hardware is still sending the
previous one. See alloc_endpoint_bulk_out_double_buffered.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".