pub struct UsbDeviceBuilder<'a, B: UsbBus> { /* private fields */ }
Expand description

Used to build new UsbDevices.

Implementations§

source§

impl<'a, B: UsbBus> UsbDeviceBuilder<'a, B>

source

pub fn new( alloc: &'a UsbBusAllocator<B>, vid_pid: UsbVidPid ) -> UsbDeviceBuilder<'a, B>

Creates a builder for constructing a new UsbDevice.

source

pub fn build(self) -> UsbDevice<'a, B>

Creates the UsbDevice instance with the configuration in this builder.

source

pub fn device_class(self, device_class: u8) -> Self

Sets the 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)

source

pub fn device_sub_class(self, device_sub_class: u8) -> Self

Sets the device sub-class code. Depends on class.

Default: 0x00

source

pub fn device_protocol(self, device_protocol: u8) -> Self

Sets the device protocol code. Depends on class and sub-class.

Default: 0x00

source

pub fn device_release(self, device_release: u16) -> Self

Sets the device release version in BCD.

Default: 0x0010 (“0.1”)

source

pub fn self_powered(self, self_powered: bool) -> Self

Sets whether the device may have an external 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

source

pub fn supports_remote_wakeup(self, supports_remote_wakeup: bool) -> Self

Sets whether the device supports remotely waking up the host is requested.

Default: false

source

pub fn usb_rev(self, usb_rev: UsbRev) -> Self

Sets which Usb 2 revision to comply to.

Default: UsbRev::Usb210

source

pub fn composite_with_iads(self) -> Self

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

source

pub fn strings( self, descriptors: &[StringDescriptors<'a>] ) -> Result<Self, BuilderError>

Specify the strings for the device.

§Note

Up to 16 languages may be provided.

source

pub fn max_packet_size_0( self, max_packet_size_0: u8 ) -> Result<Self, BuilderError>

Sets the 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

source

pub fn max_power(self, max_power_ma: usize) -> Result<Self, BuilderError>

Sets the 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

Auto Trait Implementations§

§

impl<'a, B> !RefUnwindSafe for UsbDeviceBuilder<'a, B>

§

impl<'a, B> !Send for UsbDeviceBuilder<'a, B>

§

impl<'a, B> !Sync for UsbDeviceBuilder<'a, B>

§

impl<'a, B> Unpin for UsbDeviceBuilder<'a, B>

§

impl<'a, B> !UnwindSafe for UsbDeviceBuilder<'a, B>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.