pub struct DeviceSelector { /* private fields */ }Expand description
A filter for matching devices in request_device.
§Example
use nusb::{DeviceSelector, MaybeFuture};
let devices = nusb::request_device(&[
DeviceSelector::all().with_vid_pid(0x1234, 0x5678),
DeviceSelector::all().with_vid_pid(0x1111, 0x2222),
]).wait().unwrap();Implementations§
Source§impl DeviceSelector
impl DeviceSelector
Sourcepub const fn all() -> DeviceSelector
pub const fn all() -> DeviceSelector
A selector that matches all devices.
Sourcepub const fn with_vid(self, vendor_id: u16) -> DeviceSelector
pub const fn with_vid(self, vendor_id: u16) -> DeviceSelector
Narrow the selector to only match devices with the given vendor ID.
Sourcepub const fn with_vid_pid(
self,
vendor_id: u16,
product_id: u16,
) -> DeviceSelector
pub const fn with_vid_pid( self, vendor_id: u16, product_id: u16, ) -> DeviceSelector
Narrow the selector to only match devices with the given vendor ID and product ID.
Sourcepub const fn with_class(self, class_code: u8) -> DeviceSelector
pub const fn with_class(self, class_code: u8) -> DeviceSelector
Narrow the selector to only match devices with the given class code.
Sourcepub const fn with_class_subclass(
self,
class_code: u8,
subclass_code: u8,
) -> DeviceSelector
pub const fn with_class_subclass( self, class_code: u8, subclass_code: u8, ) -> DeviceSelector
Narrow the selector to only match devices with the given class and subclass.
Sourcepub const fn with_class_subclass_protocol(
self,
class_code: u8,
subclass_code: u8,
protocol_code: u8,
) -> DeviceSelector
pub const fn with_class_subclass_protocol( self, class_code: u8, subclass_code: u8, protocol_code: u8, ) -> DeviceSelector
Narrow the selector to only match devices with the given class, subclass, and protocol.
Sourcepub fn with_serial_number(self, serial_number: String) -> DeviceSelector
pub fn with_serial_number(self, serial_number: String) -> DeviceSelector
Narrow the selector to only match devices with the given serial number.
Sourcepub fn product_id(&self) -> Option<u16>
pub fn product_id(&self) -> Option<u16>
Product ID, or None if not filtered by product ID.
Sourcepub fn serial_number(&self) -> Option<&str>
pub fn serial_number(&self) -> Option<&str>
Serial number, or None if not filtered by serial number.
Trait Implementations§
Source§impl Clone for DeviceSelector
impl Clone for DeviceSelector
Source§fn clone(&self) -> DeviceSelector
fn clone(&self) -> DeviceSelector
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DeviceSelector
impl Debug for DeviceSelector
Source§impl Default for DeviceSelector
impl Default for DeviceSelector
Source§fn default() -> DeviceSelector
fn default() -> DeviceSelector
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DeviceSelector
impl RefUnwindSafe for DeviceSelector
impl Send for DeviceSelector
impl Sync for DeviceSelector
impl Unpin for DeviceSelector
impl UnsafeUnpin for DeviceSelector
impl UnwindSafe for DeviceSelector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more