Skip to main content

DeviceSelector

Struct DeviceSelector 

Source
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

Source

pub const fn all() -> DeviceSelector

A selector that matches all devices.

Source

pub const fn with_vid(self, vendor_id: u16) -> DeviceSelector

Narrow the selector to only match devices with the given vendor ID.

Source

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.

Source

pub const fn with_class(self, class_code: u8) -> DeviceSelector

Narrow the selector to only match devices with the given class code.

Source

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.

Source

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.

Source

pub fn with_serial_number(self, serial_number: String) -> DeviceSelector

Narrow the selector to only match devices with the given serial number.

Source

pub fn vendor_id(&self) -> Option<u16>

Vendor ID, or None if not filtered by vendor ID.

Source

pub fn product_id(&self) -> Option<u16>

Product ID, or None if not filtered by product ID.

Source

pub fn class(&self) -> Option<u8>

Class code, or None if not filtered by class.

Source

pub fn subclass(&self) -> Option<u8>

Subclass code, or None if not filtered by subclass.

Source

pub fn protocol(&self) -> Option<u8>

Protocol code, or None if not filtered by protocol.

Source

pub fn serial_number(&self) -> Option<&str>

Serial number, or None if not filtered by serial number.

Trait Implementations§

Source§

impl Clone for DeviceSelector

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeviceSelector

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for DeviceSelector

Source§

fn default() -> DeviceSelector

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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

Source§

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.