Struct hidapi::DeviceInfo

source ·
pub struct DeviceInfo { /* private fields */ }
Expand description

Device information. Use accessors to extract information about Hid devices.

Note: Methods like serial_number() may return None, if the conversion to a String failed internally. You can however access the raw hid representation of the string by calling serial_number_raw()

Implementations§

source§

impl DeviceInfo

source

pub fn path(&self) -> &CStr

source

pub fn vendor_id(&self) -> u16

source

pub fn product_id(&self) -> u16

source

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

Try to call serial_number_raw(), if None is returned.

source

pub fn serial_number_raw(&self) -> Option<&[wchar_t]>

source

pub fn release_number(&self) -> u16

source

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

Try to call manufacturer_string_raw(), if None is returned.

source

pub fn manufacturer_string_raw(&self) -> Option<&[wchar_t]>

source

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

Try to call product_string_raw(), if None is returned.

source

pub fn product_string_raw(&self) -> Option<&[wchar_t]>

source

pub fn usage_page(&self) -> u16

Usage page is not available on linux libusb backends

source

pub fn usage(&self) -> u16

Usage is not available on linux libusb backends

source

pub fn interface_number(&self) -> i32

source

pub fn bus_type(&self) -> BusType

source

pub fn open_device(&self, hidapi: &HidApi) -> HidResult<HidDevice>

Use the information contained in DeviceInfo to open and return a handle to a HidDevice.

By default the device path is used to open the device. When no path is available, then vid, pid and serial number are used. If both path and serial number are not available, then this function will fail with HidError::OpenHidDeviceWithDeviceInfoError.

Note, that opening a device could still be done using HidApi::open() directly.

Trait Implementations§

source§

impl Clone for DeviceInfo

source§

fn clone(&self) -> DeviceInfo

Returns a copy 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 DeviceInfo

source§

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

Formats the value using the given formatter. 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> 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,

§

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

§

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

§

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.