pub struct HidClass<'a, B: UsbBus, D> { /* private fields */ }Expand description
Implementations§
Source§impl<'a, B: UsbBus, D: HidDevice<B>> HidClass<'a, B, D>
impl<'a, B: UsbBus, D: HidDevice<B>> HidClass<'a, B, D>
Sourcepub fn new(alloc: &'a UsbBusAllocator<B>, device: D) -> Self
pub fn new(alloc: &'a UsbBusAllocator<B>, device: D) -> Self
Create a HID class for device, allocating its interface and endpoints.
Must be called before the UsbBusAllocator is frozen by building the
device.
Sourcepub fn device_mut(&mut self) -> &mut D
pub fn device_mut(&mut self) -> &mut D
The wrapped HID function, to update its state from the main loop.
Sourcepub fn is_configured(&self) -> bool
pub fn is_configured(&self) -> bool
true once the host has configured the device.
Sourcepub fn interface(&self) -> InterfaceNumber
pub fn interface(&self) -> InterfaceNumber
Interface number allocated for this function.
Sourcepub fn report_descriptor(&self) -> &'static [u8]
pub fn report_descriptor(&self) -> &'static [u8]
Report descriptor served to the host.
Sourcepub fn send_input(&self, report: &[u8]) -> UsbResult<()>
pub fn send_input(&self, report: &[u8]) -> UsbResult<()>
Send an input report to the host.
report is the raw report, including the report ID byte when the
descriptor uses report IDs. Returns
WouldBlock when the previous report has not
been collected yet — the caller retries later.
Sourcepub fn flush(&mut self)
pub fn flush(&mut self)
Let the device send the input reports it queued.
Called automatically from every UsbClass::poll, so calling it is only
useful to shorten the latency by one loop iteration.
Trait Implementations§
Source§impl<B: UsbBus, D: HidDevice<B>> UsbClass<B> for HidClass<'_, B, D>
impl<B: UsbBus, D: HidDevice<B>> UsbClass<B> for HidClass<'_, B, D>
Source§fn configuration_descriptors(
&self,
w: &mut DescriptorWriter<'_>,
) -> UsbResult<()>
fn configuration_descriptors( &self, w: &mut DescriptorWriter<'_>, ) -> UsbResult<()>
Append this class’s interface and endpoint descriptors.
Source§fn control_in(&mut self, xfer: ControlIn<'_, B>)
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>)
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)
fn endpoint_out(&mut self, addr: EndpointAddress)
Called when endpoint
addr received an OUT packet.Source§fn deconfigure(&mut self)
fn deconfigure(&mut self)
Called when the host sends SET_CONFIGURATION(0) or on reset.
Source§fn poll(&mut self)
fn poll(&mut self)
Called unconditionally on every
UsbDevice::poll.Source§fn string(&self, index: StringIndex, lang_id: u16) -> Option<&str>
fn string(&self, index: StringIndex, lang_id: u16) -> Option<&str>
Return the string for a previously allocated
StringIndex, or None.Source§fn endpoint_in_complete(&mut self, addr: EndpointAddress)
fn endpoint_in_complete(&mut self, addr: EndpointAddress)
Called when endpoint
addr completed an IN transfer.Source§fn endpoint_setup(&mut self, addr: EndpointAddress)
fn endpoint_setup(&mut self, addr: EndpointAddress)
Called when endpoint
addr received a SETUP packet (non-EP0 control).Source§fn alt_setting(&mut self, interface: InterfaceNumber) -> Option<u8>
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
fn set_alt_setting(&mut self, interface: InterfaceNumber, alt: u8) -> bool
Set the alternate setting for
interface. Return true if handled.Auto Trait Implementations§
impl<'a, B, D> Forget for HidClass<'a, B, D>
impl<'a, B, D> Freeze for HidClass<'a, B, D>
impl<'a, B, D> Move for HidClass<'a, B, D>
impl<'a, B, D> RefUnwindSafe for HidClass<'a, B, D>where
Endpoint<'a, B, In>: RefUnwindSafe,
Option<Endpoint<'a, B, Out>>: RefUnwindSafe,
D: RefUnwindSafe,
impl<'a, B, D> Send for HidClass<'a, B, D>
impl<'a, B, D> Sync for HidClass<'a, B, D>
impl<'a, B, D> Unpin for HidClass<'a, B, D>
impl<'a, B, D> UnsafeUnpin for HidClass<'a, B, D>
impl<'a, B, D> UnwindSafe for HidClass<'a, B, D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more