pub struct DfuRuntimeClass<T: DfuRuntimeOps> { /* private fields */ }
Expand description
Implementation of DFU runtime class.
This class provides thin framework for implementing DFU runtime functionality.
When DFU_DETACH request is received, it will be accepted and DfuRuntimeOps::detach
will be called (unless DfuRuntimeOps::allow
returned false
which rejects the request).
Implementations§
Source§impl<T: DfuRuntimeOps> DfuRuntimeClass<T>
impl<T: DfuRuntimeOps> DfuRuntimeClass<T>
Sourcepub fn new<B: UsbBus>(alloc: &UsbBusAllocator<B>, ops: T) -> Self
pub fn new<B: UsbBus>(alloc: &UsbBusAllocator<B>, ops: T) -> Self
Crate new DFU run-time class with the given device-specific implementations.
Sourcepub fn tick(&mut self, elapsed_time_ms: u16)
pub fn tick(&mut self, elapsed_time_ms: u16)
Advance time
Should be called regularly, passing the time in milliseconds that has elapsed since the previous call to this function.
Sourcepub fn ops(&self) -> &T
pub fn ops(&self) -> &T
Get reference to DfuRuntimeOps
Sourcepub fn ops_mut(&mut self) -> &mut T
pub fn ops_mut(&mut self) -> &mut T
Get mutable reference to DfuRuntimeOps
Sourcepub fn interface(&self) -> InterfaceNumber
pub fn interface(&self) -> InterfaceNumber
Get class interface number
Trait Implementations§
Source§impl<T: DfuRuntimeOps, B: UsbBus> UsbClass<B> for DfuRuntimeClass<T>
impl<T: DfuRuntimeOps, B: UsbBus> UsbClass<B> for DfuRuntimeClass<T>
Source§fn 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 moreSource§fn 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
Source§fn 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
Source§fn get_bos_descriptors(
&self,
writer: &mut BosWriter<'_, '_>,
) -> Result<(), UsbError>
fn get_bos_descriptors( &self, writer: &mut BosWriter<'_, '_>, ) -> Result<(), UsbError>
Called when a GET_DESCRIPTOR request is received for a BOS descriptor.
When called, the implementation should write its blobs such as capability
descriptors into
writer
. The BOS descriptor itself will be written by
UsbDevice and shouldn’t be written by classes.Source§fn get_string(&self, index: StringIndex, lang_id: LangID) -> Option<&str>
fn get_string(&self, index: StringIndex, lang_id: LangID) -> Option<&str>
Gets a class-specific string descriptor. Read more
Source§fn 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 moreSource§fn 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 moreSource§fn 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 moreSource§fn get_alt_setting(&mut self, interface: InterfaceNumber) -> Option<u8>
fn get_alt_setting(&mut self, interface: InterfaceNumber) -> Option<u8>
Called when the interfaces alternate setting state is requested. Read more
Source§fn set_alt_setting(
&mut self,
interface: InterfaceNumber,
alternative: u8,
) -> bool
fn set_alt_setting( &mut self, interface: InterfaceNumber, alternative: u8, ) -> bool
Called when the interfaces alternate setting state is altered. Read more
Auto Trait Implementations§
impl<T> Freeze for DfuRuntimeClass<T>where
T: Freeze,
impl<T> RefUnwindSafe for DfuRuntimeClass<T>where
T: RefUnwindSafe,
impl<T> Send for DfuRuntimeClass<T>where
T: Send,
impl<T> Sync for DfuRuntimeClass<T>where
T: Sync,
impl<T> Unpin for DfuRuntimeClass<T>where
T: Unpin,
impl<T> UnwindSafe for DfuRuntimeClass<T>where
T: UnwindSafe,
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