Skip to main content

DfuDesc

Struct DfuDesc 

Source
pub struct DfuDesc {
    pub can_download: bool,
    pub can_upload: bool,
    pub manifest_tolerant: bool,
    pub will_detach: bool,
    pub detach_timeout_ms: u16,
    pub transfer_size: u16,
    pub dfu_version: (u8, u8),
}
Expand description

USB DFU (Device Firmware Upgrade) functional descriptor.

This descriptor is placed after a DFU interface descriptor and advertises the device’s DFU capabilities to the host. It is defined by the USB DFU 1.1 specification.

Use Interface::with_custom_desc to attach it to an interface:

use usb_gadget::{
    function::custom::{DfuDesc, Interface},
    Class,
};

let dfu = DfuDesc {
    can_download: true,
    can_upload: true,
    manifest_tolerant: false,
    will_detach: true,
    detach_timeout_ms: 1000,
    transfer_size: 4096,
    dfu_version: (1, 1),
};

let dfu_class = Class::DFU_RUNTIME;
let interface = Interface::new(dfu_class, "DFU").with_custom_desc(dfu.into());

Requires kernel 6.12 or later.

Fields§

§can_download: bool

Device is capable of receiving firmware via DFU.

§can_upload: bool

Device is capable of uploading firmware via DFU.

§manifest_tolerant: bool

Device is able to communicate after the manifestation phase (firmware programming) without a bus reset.

§will_detach: bool

Device will perform a bus detach-attach sequence when it receives a DFU_DETACH request. The host must not issue a USB Reset.

§detach_timeout_ms: u16

Time, in milliseconds, that the device will wait after receipt of the DFU_DETACH request. If this time elapses without a USB reset, then the device will terminate the reconfiguration phase and revert to normal operation.

§transfer_size: u16

Maximum number of bytes that the device can accept per control-write transaction.

§dfu_version: (u8, u8)

DFU specification version as (major, minor) in BCD.

For example, DFU 1.1 is (1, 1).

Trait Implementations§

Source§

impl Clone for DfuDesc

Source§

fn clone(&self) -> DfuDesc

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DfuDesc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for DfuDesc

Source§

impl From<DfuDesc> for CustomDesc

Source§

fn from(dfu: DfuDesc) -> Self

Converts to this type from the input type.
Source§

impl Hash for DfuDesc

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for DfuDesc

Source§

fn eq(&self, other: &DfuDesc) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DfuDesc

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.