Struct embassy_usb::Config

source ·
pub struct Config<'a> { pub device_class: u8, pub device_sub_class: u8, pub device_protocol: u8, pub device_release: u16, pub max_packet_size_0: u8, pub manufacturer: Option<&'a str>, pub product: Option<&'a str>, pub serial_number: Option<&'a str>, pub supports_remote_wakeup: bool, pub composite_with_iads: bool, pub self_powered: bool, pub max_power: u16, /* private fields */ }
Expand description

Configuration used when creating UsbDevice.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§device_class: u8

Device class code assigned by USB.org. Set to 0xff for vendor-specific devices that do not conform to any class.

Default: 0x00 (class code specified by interfaces)

§device_sub_class: u8

Device sub-class code. Depends on class.

Default: 0x00

§device_protocol: u8

Device protocol code. Depends on class and sub-class.

Default: 0x00

§device_release: u16

Device release version in BCD.

Default: 0x0010 (“0.1”)

§max_packet_size_0: u8

Maximum packet size in bytes for the control endpoint 0.

Valid values depend on the speed at which the bus is enumerated.

  • low speed: 8
  • full speed: 8, 16, 32, or 64
  • high speed: 64

Default: 64 bytes

§manufacturer: Option<&'a str>

Manufacturer name string descriptor.

Default: (none)

§product: Option<&'a str>

Product name string descriptor.

Default: (none)

§serial_number: Option<&'a str>

Serial number string descriptor.

Default: (none)

§supports_remote_wakeup: bool

Whether the device supports remotely waking up the host is requested.

Default: false

§composite_with_iads: bool

Configures the device as a composite device with interface association descriptors.

If set to true, the following fields should have the given values:

  • device_class = 0xEF
  • device_sub_class = 0x02
  • device_protocol = 0x01
§self_powered: bool

Whether the device has its own power source.

This should be set to true even if the device is sometimes self-powered and may not always draw power from the USB bus.

Default: false

See also: max_power

§max_power: u16

Maximum current drawn from the USB bus by the device, in milliamps.

The default is 100 mA. If your device always uses an external power source and never draws power from the USB bus, this can be set to 0.

See also: self_powered

Default: 100mA Max: 500mA



impl<'a> Config<'a>


pub const fn new(vid: u16, pid: u16) -> Self

Create default configuration with the provided vid and pid values.

Trait Implementations§


impl<'a> Clone for Config<'a>


fn clone(&self) -> Config<'a>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more

impl<'a> Debug for Config<'a>


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

Formats the value using the given formatter. Read more

impl<'a> Format for Config<'a>


fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.

impl<'a> Copy for Config<'a>

Auto Trait Implementations§


impl<'a> Freeze for Config<'a>


impl<'a> RefUnwindSafe for Config<'a>


impl<'a> Send for Config<'a>


impl<'a> Sync for Config<'a>


impl<'a> Unpin for Config<'a>


impl<'a> UnwindSafe for Config<'a>

Blanket Implementations§


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


fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more

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


fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more

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


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

Mutably borrows from an owned value. Read more

impl<T> From<T> for T


fn from(t: T) -> T

Returns the argument unchanged.


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


fn into(self) -> U

Calls U::from(self).

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


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


type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

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


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

The type returned in the event of a conversion error.

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

Performs the conversion.