Skip to main content

UsbClass

Trait UsbClass 

Source
pub trait UsbClass<B: UsbBus> {
Show 13 methods // Provided methods fn configuration_descriptors( &self, writer: &mut DescriptorWriter<'_>, ) -> UsbResult<()> { ... } fn string(&self, index: StringIndex, lang_id: u16) -> Option<&str> { ... } fn control_in(&mut self, xfer: ControlIn<'_, B>) { ... } fn control_out(&mut self, xfer: ControlOut<'_, B>) { ... } fn endpoint_out(&mut self, addr: EndpointAddress) { ... } fn endpoint_in_complete(&mut self, addr: EndpointAddress) { ... } fn endpoint_setup(&mut self, addr: EndpointAddress) { ... } fn reset(&mut self) { ... } fn configure(&mut self) { ... } fn deconfigure(&mut self) { ... } fn poll(&mut self) { ... } fn alt_setting(&mut self, interface: InterfaceNumber) -> Option<u8> { ... } fn set_alt_setting(&mut self, interface: InterfaceNumber, alt: u8) -> bool { ... }
}
Expand description

USB device class trait.

All methods have default no-op implementations. Override only the ones your class needs.

Provided Methods§

Source

fn configuration_descriptors( &self, writer: &mut DescriptorWriter<'_>, ) -> UsbResult<()>

Append this class’s interface and endpoint descriptors.

Source

fn string(&self, index: StringIndex, lang_id: u16) -> Option<&str>

Return the string for a previously allocated StringIndex, or None.

Source

fn control_in(&mut self, xfer: ControlIn<'_, B>)

Handle a control IN transfer. Accept, reject, or pass (drop without acting).

Source

fn control_out(&mut self, xfer: ControlOut<'_, B>)

Handle a control OUT transfer. Accept, reject, or pass (drop without acting).

Source

fn endpoint_out(&mut self, addr: EndpointAddress)

Called when endpoint addr received an OUT packet.

Source

fn endpoint_in_complete(&mut self, addr: EndpointAddress)

Called when endpoint addr completed an IN transfer.

Source

fn endpoint_setup(&mut self, addr: EndpointAddress)

Called when endpoint addr received a SETUP packet (non-EP0 control).

Source

fn reset(&mut self)

Called after a USB bus reset.

Source

fn configure(&mut self)

Called when the host sends SET_CONFIGURATION(1).

Source

fn deconfigure(&mut self)

Called when the host sends SET_CONFIGURATION(0) or on reset.

Source

fn poll(&mut self)

Called unconditionally on every UsbDevice::poll.

Source

fn alt_setting(&mut self, interface: InterfaceNumber) -> Option<u8>

Return the current alternate setting for interface, or None.

Source

fn set_alt_setting(&mut self, interface: InterfaceNumber, alt: u8) -> bool

Set the alternate setting for interface. Return true if handled.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<B: UsbBus, D: HidDevice<B>> UsbClass<B> for HidClass<'_, B, D>

Source§

impl<B: UsbBus, I: I2cBus> UsbClass<B> for I2cTinyUsb<I>

Source§

impl<B: UsbBus> UsbClass<B> for AudioClass<'_, B>

Source§

impl<B: UsbBus> UsbClass<B> for CdcAcm<'_, B>

Source§

impl<B: UsbBus> UsbClass<B> for GsUsbClass<'_, B>