pub trait BackendDevice: Sync + Send {
Show 15 methods
// Required methods
fn submit_backend_transfer(
&mut self,
transfer: BackendTransferType
) -> Result<BackendTransferHandle>;
fn detach_event_handler(&self, event_loop: &Arc<EventLoop>) -> Result<()>;
fn request_transfer_buffer(&mut self, size: usize) -> TransferBuffer;
fn build_bulk_transfer(
&mut self,
ep_addr: u8,
transfer_buffer: TransferBuffer,
stream_id: Option<u16>
) -> Result<BackendTransferType>;
fn build_interrupt_transfer(
&mut self,
ep_addr: u8,
transfer_buffer: TransferBuffer
) -> Result<BackendTransferType>;
fn get_control_transfer_state(
&mut self
) -> Arc<RwLock<ControlTransferState>>;
fn get_device_state(&mut self) -> Arc<RwLock<DeviceState>>;
fn get_active_config_descriptor(&mut self) -> Result<ConfigDescriptorTree>;
fn get_config_descriptor(
&mut self,
config: u8
) -> Result<ConfigDescriptorTree>;
fn get_config_descriptor_by_index(
&mut self,
config_index: u8
) -> Result<ConfigDescriptorTree>;
fn get_device_descriptor_tree(&mut self) -> Result<DeviceDescriptorTree>;
fn get_active_configuration(&mut self) -> Result<u8>;
fn set_active_configuration(&mut self, config: u8) -> Result<()>;
fn clear_feature(
&mut self,
value: u16,
index: u16
) -> Result<TransferStatus>;
fn create_endpoints(
&mut self,
config_descriptor: &ConfigDescriptorTree
) -> Result<()>;
}
Expand description
Backend device trait implementation is the interface of a generic backend device to interact with concrete implementations
Required Methods§
sourcefn submit_backend_transfer(
&mut self,
transfer: BackendTransferType
) -> Result<BackendTransferHandle>
fn submit_backend_transfer( &mut self, transfer: BackendTransferType ) -> Result<BackendTransferHandle>
Submits a transfer to the specific backend implementation.
sourcefn detach_event_handler(&self, event_loop: &Arc<EventLoop>) -> Result<()>
fn detach_event_handler(&self, event_loop: &Arc<EventLoop>) -> Result<()>
This is called by a generic backend provider when a USB detach message is received from the vm control socket. It detaches the backend device from the backend provider event loop.
sourcefn request_transfer_buffer(&mut self, size: usize) -> TransferBuffer
fn request_transfer_buffer(&mut self, size: usize) -> TransferBuffer
Gets a buffer used for data transfer between the host and this device. The buffer returned
by this function must be consumed by submit_backend_transfer()
.
sourcefn build_bulk_transfer(
&mut self,
ep_addr: u8,
transfer_buffer: TransferBuffer,
stream_id: Option<u16>
) -> Result<BackendTransferType>
fn build_bulk_transfer( &mut self, ep_addr: u8, transfer_buffer: TransferBuffer, stream_id: Option<u16> ) -> Result<BackendTransferType>
Requests the backend to build a backend-specific bulk transfer request
sourcefn build_interrupt_transfer(
&mut self,
ep_addr: u8,
transfer_buffer: TransferBuffer
) -> Result<BackendTransferType>
fn build_interrupt_transfer( &mut self, ep_addr: u8, transfer_buffer: TransferBuffer ) -> Result<BackendTransferType>
Requests the backend to build a backend-specific interrupt transfer request
sourcefn get_control_transfer_state(&mut self) -> Arc<RwLock<ControlTransferState>>
fn get_control_transfer_state(&mut self) -> Arc<RwLock<ControlTransferState>>
Returns the ControlTransferState
for the given backend device.
sourcefn get_device_state(&mut self) -> Arc<RwLock<DeviceState>>
fn get_device_state(&mut self) -> Arc<RwLock<DeviceState>>
Returns the DeviceState
for the given backend device. This state contains all the
backend-agnostic state for all generic USB backends.
sourcefn get_active_config_descriptor(&mut self) -> Result<ConfigDescriptorTree>
fn get_active_config_descriptor(&mut self) -> Result<ConfigDescriptorTree>
Gets the device active config descriptor tree.
sourcefn get_config_descriptor(&mut self, config: u8) -> Result<ConfigDescriptorTree>
fn get_config_descriptor(&mut self, config: u8) -> Result<ConfigDescriptorTree>
Gets a specific device config descriptor tree.
sourcefn get_config_descriptor_by_index(
&mut self,
config_index: u8
) -> Result<ConfigDescriptorTree>
fn get_config_descriptor_by_index( &mut self, config_index: u8 ) -> Result<ConfigDescriptorTree>
Gets a specific device config descriptor tree by index.
sourcefn get_device_descriptor_tree(&mut self) -> Result<DeviceDescriptorTree>
fn get_device_descriptor_tree(&mut self) -> Result<DeviceDescriptorTree>
Gets the device descriptor tree.
sourcefn get_active_configuration(&mut self) -> Result<u8>
fn get_active_configuration(&mut self) -> Result<u8>
Gets the device current active configuration.
sourcefn set_active_configuration(&mut self, config: u8) -> Result<()>
fn set_active_configuration(&mut self, config: u8) -> Result<()>
Sets the device active configuration.
sourcefn clear_feature(&mut self, value: u16, index: u16) -> Result<TransferStatus>
fn clear_feature(&mut self, value: u16, index: u16) -> Result<TransferStatus>
Handles a clear feature endpoint request for the given device.
sourcefn create_endpoints(
&mut self,
config_descriptor: &ConfigDescriptorTree
) -> Result<()>
fn create_endpoints( &mut self, config_descriptor: &ConfigDescriptorTree ) -> Result<()>
Creates endpoints for the device with the given config descriptor tree.