Struct usb_device::prelude::UsbDeviceBuilder
source · [−]pub struct UsbDeviceBuilder<'a, B: UsbBus> { /* private fields */ }
Expand description
Used to build new UsbDevice
s.
Implementations
sourceimpl<'a, B: UsbBus> UsbDeviceBuilder<'a, B>
impl<'a, B: UsbBus> UsbDeviceBuilder<'a, B>
sourcepub fn new(
alloc: &'a UsbBusAllocator<B>,
vid_pid: UsbVidPid
) -> UsbDeviceBuilder<'a, B>
pub fn new(
alloc: &'a UsbBusAllocator<B>,
vid_pid: UsbVidPid
) -> UsbDeviceBuilder<'a, B>
Creates a builder for constructing a new UsbDevice
.
sourcepub fn build(self) -> UsbDevice<'a, B>
pub fn build(self) -> UsbDevice<'a, B>
Creates the UsbDevice
instance with the configuration in this builder.
sourcepub fn device_class(self, device_class: u8) -> Self
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)
sourcepub fn device_sub_class(self, device_sub_class: u8) -> Self
pub fn device_sub_class(self, device_sub_class: u8) -> Self
Sets the device sub-class code. Depends on class.
Default: 0x00
sourcepub fn device_protocol(self, device_protocol: u8) -> Self
pub fn device_protocol(self, device_protocol: u8) -> Self
Sets the device protocol code. Depends on class and sub-class.
Default: 0x00
sourcepub fn device_release(self, device_release: u16) -> Self
pub fn device_release(self, device_release: u16) -> Self
Sets the device release version in BCD.
Default: 0x0010
(“0.1”)
sourcepub fn self_powered(self, self_powered: bool) -> Self
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
sourcepub fn supports_remote_wakeup(self, supports_remote_wakeup: bool) -> Self
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
sourcepub fn composite_with_iads(self) -> Self
pub fn composite_with_iads(self) -> Self
Configures the device as a composite device with interface association descriptors.
sourcepub fn manufacturer(self, manufacturer: &'a str) -> Self
pub fn manufacturer(self, manufacturer: &'a str) -> Self
Sets the manufacturer name string descriptor.
Default: (none)
sourcepub fn product(self, product: &'a str) -> Self
pub fn product(self, product: &'a str) -> Self
Sets the product name string descriptor.
Default: (none)
sourcepub fn serial_number(self, serial_number: &'a str) -> Self
pub fn serial_number(self, serial_number: &'a str) -> Self
Sets the serial number string descriptor.
Default: (none)
sourcepub fn max_packet_size_0(self, max_packet_size_0: u8) -> Self
pub fn max_packet_size_0(self, max_packet_size_0: u8) -> Self
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
sourcepub fn max_power(self, max_power_ma: usize) -> Self
pub fn max_power(self, max_power_ma: usize) -> Self
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