Struct DeviceInfo

Source
pub struct DeviceInfo { /* private fields */ }
Expand description

Corresponds to android.hardware.usb.UsbDevice. Its fields and the InterfaceInfo list are read on creation and will not be updated automatically; however, PartialEq depends on these fields.

Implementations§

Source§

impl DeviceInfo

Source

pub fn has_permission(&self) -> Result<bool, Error>

Returns true if the caller has permission to access the device.

Source

pub fn check_connection(&self) -> bool

Checks if the device is still in the list of connected devices. Note: The implementation can be optimized.

Source

pub fn request_permission(&self) -> Result<Option<PermissionRequest>, Error>

Performs a permission request for the device.

Returns Ok(None) if the permission is already granted. Otherwise it returns a PermissionRequest handler.

The activity might be paused by requestPermission() here, but resumed on receving result. The state of PermissionRequest can be checked on android_activity::MainEvent::Resume, Otherwise block in a background thread (it wouldn’t be paused/resumed automatically).

Source

pub fn open_device(&self) -> Result<Device, Error>

Opens the device. Returns error PermissionDenied if the permission is not granted.

Source§

impl DeviceInfo

Source

pub fn vendor_id(&self) -> u16

Equals idVendor.

Source

pub fn product_id(&self) -> u16

Equals idProduct.

Source

pub fn class(&self) -> u8

Equals bDeviceClass.

Source

pub fn subclass(&self) -> u8

Equals bDeviceSubClass.

Source

pub fn protocol(&self) -> u8

Equals bDeviceProtocol.

Source§

impl DeviceInfo

Source

pub fn path_name(&self) -> &String

(usually) Path of the device in the usbfs file system.

Source

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

Vendor name.

Source

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

Product name.

Source

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

USB protocol version.

Source

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

Device serial ID string. FIXME: On Android 10 and above, this is always None if this struct is created before gaining permission for the device. To read it, call list_devices() and find the device again after the permission is granted.

Source§

impl DeviceInfo

Source

pub fn interfaces(&self) -> impl Iterator<Item = &InterfaceInfo>

Iterator over the device’s interfaces.

Trait Implementations§

Source§

impl Clone for DeviceInfo

Source§

fn clone(&self) -> DeviceInfo

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 DeviceInfo

Source§

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

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

impl PartialEq for DeviceInfo

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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.