Struct usb_device::test_class::TestClass
source · [−]pub struct TestClass<'a, B: UsbBus> { /* private fields */ }
Expand description
Test USB class for testing USB driver implementations. Supports various endpoint types and requests for testing USB peripheral drivers on actual hardware.
Implementations
sourceimpl<B: UsbBus> TestClass<'_, B>
impl<B: UsbBus> TestClass<'_, B>
sourcepub fn new(alloc: &UsbBusAllocator<B>) -> TestClass<'_, B>
pub fn new(alloc: &UsbBusAllocator<B>) -> TestClass<'_, B>
Creates a new TestClass.
sourcepub fn make_device<'a, 'b>(
&'a self,
usb_bus: &'b UsbBusAllocator<B>
) -> UsbDevice<'b, B>
pub fn make_device<'a, 'b>(
&'a self,
usb_bus: &'b UsbBusAllocator<B>
) -> UsbDevice<'b, B>
Convenience method to create a UsbDevice that is configured correctly for TestClass.
sourcepub fn make_device_builder<'a, 'b>(
&'a self,
usb_bus: &'b UsbBusAllocator<B>
) -> UsbDeviceBuilder<'b, B>
pub fn make_device_builder<'a, 'b>(
&'a self,
usb_bus: &'b UsbBusAllocator<B>
) -> UsbDeviceBuilder<'b, B>
Convenience method to create a UsbDeviceBuilder that is configured correctly for TestClass.
The methods sets
- manufacturer
- product
- serial number
- max_packet_size_0
on the returned builder. If you change the manufacturer, product, or serial number fields, the test host may misbehave.
Trait Implementations
sourceimpl<B: UsbBus> UsbClass<B> for TestClass<'_, B>
impl<B: UsbBus> UsbClass<B> for TestClass<'_, B>
sourcefn get_configuration_descriptors(
&self,
writer: &mut DescriptorWriter<'_>
) -> Result<()>
fn get_configuration_descriptors(
&self,
writer: &mut DescriptorWriter<'_>
) -> Result<()>
Called when a GET_DESCRIPTOR request is received for a configuration descriptor. When
called, the implementation should write its interface, endpoint and any extra class
descriptors into
writer
. The configuration descriptor itself will be written by
UsbDevice and shouldn’t be written by classes. Read moresourcefn get_string(&self, index: StringIndex, lang_id: u16) -> Option<&str>
fn get_string(&self, index: StringIndex, lang_id: u16) -> Option<&str>
Gets a class-specific string descriptor. Read more
sourcefn endpoint_in_complete(&mut self, addr: EndpointAddress)
fn endpoint_in_complete(&mut self, addr: EndpointAddress)
Called when endpoint with address
addr
has completed transmitting data (IN packet). Read moresourcefn endpoint_out(&mut self, addr: EndpointAddress)
fn endpoint_out(&mut self, addr: EndpointAddress)
Called when endpoint with address
addr
has received data (OUT packet). Read moresourcefn control_in(&mut self, xfer: ControlIn<'_, '_, '_, B>)
fn control_in(&mut self, xfer: ControlIn<'_, '_, '_, B>)
Called when a control request is received with direction DeviceToHost. Read more
sourcefn control_out(&mut self, xfer: ControlOut<'_, '_, '_, B>)
fn control_out(&mut self, xfer: ControlOut<'_, '_, '_, B>)
Called when a control request is received with direction HostToDevice. Read more
sourcefn get_bos_descriptors(&self, writer: &mut BosWriter<'_, '_>) -> Result<()>
fn get_bos_descriptors(&self, writer: &mut BosWriter<'_, '_>) -> Result<()>
sourcefn endpoint_setup(&mut self, addr: EndpointAddress)
fn endpoint_setup(&mut self, addr: EndpointAddress)
Called when endpoint with address
addr
has received a SETUP packet. Implementing this
shouldn’t be necessary in most cases, but is provided for completeness’ sake. Read moreAuto Trait Implementations
impl<'a, B> RefUnwindSafe for TestClass<'a, B>
impl<'a, B> Send for TestClass<'a, B>
impl<'a, B> Sync for TestClass<'a, B>
impl<'a, B> Unpin for TestClass<'a, B>
impl<'a, B> UnwindSafe for TestClass<'a, B>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more