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 are 8, 16, 32 and 64. There’s generally no need to change this from the default value of 8 bytes unless a class uses control transfers for sending large amounts of data, in which case using a larger packet size may be more efficient.

Default: 8 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 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> 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 Twhere
T: 'static + ?Sized,


fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.


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

const: unstable · 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.


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


type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.

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


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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.