pub trait Driver<'a> {
type EndpointOut: EndpointOut + 'a;
type EndpointIn: EndpointIn + 'a;
type Bus: Bus + 'a;
// Required methods
fn alloc_endpoint_out(
&mut self,
config: &EndpointConfig,
) -> Result<Self::EndpointOut, EndpointAllocError>;
fn alloc_endpoint_in(
&mut self,
config: &EndpointConfig,
) -> Result<Self::EndpointIn, EndpointAllocError>;
fn start(self, control_max_packet_size: u16) -> Self::Bus;
}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.
Required Methods§
Sourcefn alloc_endpoint_out(
&mut self,
config: &EndpointConfig,
) -> Result<Self::EndpointOut, EndpointAllocError>
fn alloc_endpoint_out( &mut self, config: &EndpointConfig, ) -> Result<Self::EndpointOut, EndpointAllocError>
Allocates an OUT endpoint.
This method is called by the USB stack to allocate endpoints.
It can only be called before start is called.
Sourcefn alloc_endpoint_in(
&mut self,
config: &EndpointConfig,
) -> Result<Self::EndpointIn, EndpointAllocError>
fn alloc_endpoint_in( &mut self, config: &EndpointConfig, ) -> Result<Self::EndpointIn, EndpointAllocError>
Allocates an IN endpoint.
This method is called by the USB stack to allocate endpoints.
It can only be called before start is called.
Sourcefn start(self, control_max_packet_size: u16) -> Self::Bus
fn start(self, control_max_packet_size: u16) -> Self::Bus
Start operation of the USB device.
This returns the Bus instance that is used to operate the USB device, including its
control pipe. 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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".