Struct Device

Source
pub struct Device<'a> { /* private fields */ }
Expand description

The HID device.

Implementations§

Source§

impl<'a> Device<'a>

Source

pub fn path(&self) -> &Path

The path representation.

Examples found in repository?
examples/list.rs (line 7)
3fn main() {
4	let hid = hid::init().unwrap();
5
6	for device in hid.devices() {
7		print!("{} ", device.path().to_str().unwrap());
8		print!("ID {:x}:{:x} ", device.vendor_id(), device.product_id());
9
10		if let Some(name) = device.manufacturer_string() {
11			print!("{} ", name);
12		}
13
14		if let Some(name) = device.product_string() {
15			print!("{} ", name);
16		}
17
18		if let Some(name) = device.serial_number() {
19			print!("{} ", name);
20		}
21
22		println!();
23	}
24}
Source

pub fn vendor_id(&self) -> u16

The vendor ID.

Examples found in repository?
examples/list.rs (line 8)
3fn main() {
4	let hid = hid::init().unwrap();
5
6	for device in hid.devices() {
7		print!("{} ", device.path().to_str().unwrap());
8		print!("ID {:x}:{:x} ", device.vendor_id(), device.product_id());
9
10		if let Some(name) = device.manufacturer_string() {
11			print!("{} ", name);
12		}
13
14		if let Some(name) = device.product_string() {
15			print!("{} ", name);
16		}
17
18		if let Some(name) = device.serial_number() {
19			print!("{} ", name);
20		}
21
22		println!();
23	}
24}
Source

pub fn product_id(&self) -> u16

The product ID.

Examples found in repository?
examples/list.rs (line 8)
3fn main() {
4	let hid = hid::init().unwrap();
5
6	for device in hid.devices() {
7		print!("{} ", device.path().to_str().unwrap());
8		print!("ID {:x}:{:x} ", device.vendor_id(), device.product_id());
9
10		if let Some(name) = device.manufacturer_string() {
11			print!("{} ", name);
12		}
13
14		if let Some(name) = device.product_string() {
15			print!("{} ", name);
16		}
17
18		if let Some(name) = device.serial_number() {
19			print!("{} ", name);
20		}
21
22		println!();
23	}
24}
Source

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

The serial number.

Examples found in repository?
examples/list.rs (line 18)
3fn main() {
4	let hid = hid::init().unwrap();
5
6	for device in hid.devices() {
7		print!("{} ", device.path().to_str().unwrap());
8		print!("ID {:x}:{:x} ", device.vendor_id(), device.product_id());
9
10		if let Some(name) = device.manufacturer_string() {
11			print!("{} ", name);
12		}
13
14		if let Some(name) = device.product_string() {
15			print!("{} ", name);
16		}
17
18		if let Some(name) = device.serial_number() {
19			print!("{} ", name);
20		}
21
22		println!();
23	}
24}
Source

pub fn manufacturer_string(&self) -> Option<String>

The manufacturer string.

Examples found in repository?
examples/list.rs (line 10)
3fn main() {
4	let hid = hid::init().unwrap();
5
6	for device in hid.devices() {
7		print!("{} ", device.path().to_str().unwrap());
8		print!("ID {:x}:{:x} ", device.vendor_id(), device.product_id());
9
10		if let Some(name) = device.manufacturer_string() {
11			print!("{} ", name);
12		}
13
14		if let Some(name) = device.product_string() {
15			print!("{} ", name);
16		}
17
18		if let Some(name) = device.serial_number() {
19			print!("{} ", name);
20		}
21
22		println!();
23	}
24}
Source

pub fn product_string(&self) -> Option<String>

The product string.

Examples found in repository?
examples/list.rs (line 14)
3fn main() {
4	let hid = hid::init().unwrap();
5
6	for device in hid.devices() {
7		print!("{} ", device.path().to_str().unwrap());
8		print!("ID {:x}:{:x} ", device.vendor_id(), device.product_id());
9
10		if let Some(name) = device.manufacturer_string() {
11			print!("{} ", name);
12		}
13
14		if let Some(name) = device.product_string() {
15			print!("{} ", name);
16		}
17
18		if let Some(name) = device.serial_number() {
19			print!("{} ", name);
20		}
21
22		println!();
23	}
24}
Source

pub fn release_number(&self) -> u16

The release number.

Source

pub fn usage_page(&self) -> u16

The usage page.

Source

pub fn usage(&self) -> u16

The usage number.

Source

pub fn interface_number(&self) -> isize

The interface number.

Source

pub fn open(&self) -> Result<Handle>

Opens the device to use it.

Auto Trait Implementations§

§

impl<'a> Freeze for Device<'a>

§

impl<'a> RefUnwindSafe for Device<'a>

§

impl<'a> !Send for Device<'a>

§

impl<'a> !Sync for Device<'a>

§

impl<'a> Unpin for Device<'a>

§

impl<'a> UnwindSafe for Device<'a>

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

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.