Device

Struct Device 

Source
pub struct Device(/* private fields */);
Available on Android or Linux only.

Implementations§

Source§

impl Device

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>

Examples found in repository?
examples/device.rs (line 6)
5fn print_info<P: AsRef<Path>>(path: P) -> Result<()> {
6	let mut device = Device::open(path)?;
7
8	println!("{device:#?}");
9	println!("\t{:?}", device.get_physical_address()?);
10	println!("\t{:?}", device.get_report_descriptor()?);
11	println!("\t{:?}", device.get_raw_unique()?);
12
13	Ok(())
14}
Source§

impl Device

Source

pub fn get_feature_report<T>(&mut self, report_id: u8) -> Result<T>

Request a feature report using HIDIOCGFEATURE ioctl.

Source

pub unsafe fn get_feature_report_with_size<T>( &mut self, report_id: u8, size: usize, ) -> Result<T>

Available on crate feature unsafe_reports only.

Request a feature report using HIDIOCGFEATURE ioctl with specific size.

§Safety

Calling this function with size > size_of::<T>() is undefined behaviour.

Source

pub fn get_input_report<T>(&mut self, report_id: u8) -> Result<T>

Request an input report using HIDIOCGINPUT ioctl.

Source

pub unsafe fn get_input_report_with_size<T>( &mut self, report_id: u8, size: usize, ) -> Result<T>

Available on crate feature unsafe_reports only.

Request an input report using HIDIOCGINPUT ioctl with specific size.

§Safety

Calling this function with size > size_of::<T>() is undefined behaviour.

Source

pub fn get_input_report_read<T>(&mut self, report_id: u8) -> Result<T>

Request an input report using read.

Source

pub unsafe fn get_input_report_read_with_size<T>( &mut self, report_id: u8, size: usize, ) -> Result<T>

Available on crate feature unsafe_reports only.

Request an input report using read with specific size.

§Safety

Calling this function with size > size_of::<T>() is undefined behaviour.

Source

pub fn get_output_report<T>(&mut self, report_id: u8) -> Result<T>

Request an output report using HIDIOCGOUTPUT ioctl.

Source

pub unsafe fn get_output_report_with_size<T>( &mut self, report_id: u8, size: usize, ) -> Result<T>

Available on crate feature unsafe_reports only.

Request an output report using HIDIOCGOUTPUT ioctl with specific size.

§Safety

Calling this function with size > size_of::<T>() is undefined behaviour.

Source

pub fn get_physical_address(&mut self) -> Result<String>

Examples found in repository?
examples/device.rs (line 9)
5fn print_info<P: AsRef<Path>>(path: P) -> Result<()> {
6	let mut device = Device::open(path)?;
7
8	println!("{device:#?}");
9	println!("\t{:?}", device.get_physical_address()?);
10	println!("\t{:?}", device.get_report_descriptor()?);
11	println!("\t{:?}", device.get_raw_unique()?);
12
13	Ok(())
14}
Source

pub fn get_raw_info(&mut self) -> Result<RawInfo>

Source

pub fn get_raw_name(&mut self) -> Result<String>

Source

pub fn get_raw_unique(&mut self) -> Result<String>

Examples found in repository?
examples/device.rs (line 11)
5fn print_info<P: AsRef<Path>>(path: P) -> Result<()> {
6	let mut device = Device::open(path)?;
7
8	println!("{device:#?}");
9	println!("\t{:?}", device.get_physical_address()?);
10	println!("\t{:?}", device.get_report_descriptor()?);
11	println!("\t{:?}", device.get_raw_unique()?);
12
13	Ok(())
14}
Source

pub fn get_report_descriptor(&mut self) -> Result<Vec<u8>>

Examples found in repository?
examples/device.rs (line 10)
5fn print_info<P: AsRef<Path>>(path: P) -> Result<()> {
6	let mut device = Device::open(path)?;
7
8	println!("{device:#?}");
9	println!("\t{:?}", device.get_physical_address()?);
10	println!("\t{:?}", device.get_report_descriptor()?);
11	println!("\t{:?}", device.get_raw_unique()?);
12
13	Ok(())
14}
Source

pub fn send_feature_report<T>(&mut self, report: &T) -> Result<()>

Send a feature report using HIDIOCSFEATURE ioctl.

Source

pub unsafe fn send_feature_report_with_size<T>( &mut self, report: &T, size: usize, ) -> Result<()>

Available on crate feature unsafe_reports only.

Send a feature report using HIDIOCSFEATURE ioctl with specific size.

§Safety

Calling this function with size > size_of::<T>() is undefined behaviour.

Source

pub fn send_input_report<T>(&mut self, report: &T) -> Result<()>

Send an input report using HIDIOCSINPUT ioctl.

Source

pub unsafe fn send_input_report_with_size<T>( &mut self, report: &T, size: usize, ) -> Result<()>

Available on crate feature unsafe_reports only.

Send an input report using HIDIOCSINPUT ioctl with specific size.

§Safety

Calling this function with size > size_of::<T>() is undefined behaviour.

Source

pub fn send_output_report<T>(&mut self, report: &T) -> Result<()>

Send an output report using HIDIOCSOUTPUT ioctl.

Source

pub unsafe fn send_output_report_with_size<T>( &mut self, report: &T, size: usize, ) -> Result<()>

Available on crate feature unsafe_reports only.

Send an output report using HIDIOCSOUTPUT ioctl with specific size.

§Safety

Calling this function with size > size_of::<T>() is undefined behaviour.

Source

pub fn send_output_report_write<T>(&mut self, report: &T) -> Result<()>

Send an output report using write.

Source

pub unsafe fn send_output_report_write_with_size<T>( &mut self, report: &T, size: usize, ) -> Result<()>

Available on crate feature unsafe_reports only.

Send an output report using write with specific size.

§Safety

Calling this function with size > size_of::<T>() is undefined behaviour.

Trait Implementations§

Source§

impl AsFd for Device

Source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more
Source§

impl AsRawFd for Device

Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
Source§

impl Debug for Device

Source§

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

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

impl From<Device> for OwnedFd

Source§

fn from(device: Device) -> Self

Converts to this type from the input type.
Source§

impl From<OwnedFd> for Device

Source§

fn from(owned_fd: OwnedFd) -> Self

Converts to this type from the input type.
Source§

impl FromRawFd for Device

Source§

unsafe fn from_raw_fd(fd: RawFd) -> Self

Constructs a new instance of Self from the given raw file descriptor. Read more
Source§

impl IntoRawFd for Device

Source§

fn into_raw_fd(self) -> RawFd

Consumes this object, returning the raw underlying file descriptor. Read more

Auto Trait Implementations§

§

impl Freeze for Device

§

impl RefUnwindSafe for Device

§

impl Send for Device

§

impl Sync for Device

§

impl Unpin for Device

§

impl UnwindSafe for Device

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.