Struct USBDevice

Source
pub struct USBDevice {
    pub vendor_id: String,
    pub product_id: String,
    pub vendor_name: String,
    pub product_name: String,
    pub device_class: String,
    pub usb_version: String,
    pub serial_number: Option<String>,
    pub bus_number: u8,
    pub device_address: u8,
    pub port_path: Option<String>,
    pub driver: Option<String>,
    pub connected: bool,
}
Expand description

USB device information

Fields§

§vendor_id: String

USB vendor ID

§product_id: String

USB product ID

§vendor_name: String

Vendor name

§product_name: String

Product name

§device_class: String

USB device class

§usb_version: String

USB version (1.0, 1.1, 2.0, 3.0, etc.)

§serial_number: Option<String>

Serial number (if available)

§bus_number: u8

Bus number

§device_address: u8

Device address

§port_path: Option<String>

Port path

§driver: Option<String>

Driver name (if loaded)

§connected: bool

Is device currently connected

Implementations§

Source§

impl USBDevice

Source

pub fn query_all() -> Result<Vec<Self>>

Query all USB devices

Source

pub fn vendor_id(&self) -> &str

Get vendor ID

Source

pub fn product_id(&self) -> &str

Get product ID

Source

pub fn vendor_name(&self) -> &str

Get vendor name

Source

pub fn product_name(&self) -> &str

Get product name

Source

pub fn device_class(&self) -> &str

Get device class

Source

pub fn usb_version(&self) -> &str

Get USB version

Source

pub fn is_connected(&self) -> bool

Check if device is connected

Source

pub fn is_storage_device(&self) -> bool

Check if device is a storage device

Source

pub fn is_input_device(&self) -> bool

Check if device is an input device

Source

pub fn is_audio_device(&self) -> bool

Check if device is an audio device

Source

pub fn is_video_device(&self) -> bool

Check if device is a video device

Source

pub fn is_high_speed(&self) -> bool

Check if device supports USB 3.0 or higher

Trait Implementations§

Source§

impl Clone for USBDevice

Source§

fn clone(&self) -> USBDevice

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for USBDevice

Source§

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

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

impl<'de> Deserialize<'de> for USBDevice

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for USBDevice

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,