[−][src]Struct libusb::DeviceHandle
A handle to an open USB device.
Methods
impl<'a> DeviceHandle<'a>
[src]
impl<'a> DeviceHandle<'a>
pub fn active_configuration(&self) -> Result<u8>
[src]
pub fn active_configuration(&self) -> Result<u8>
Returns the active configuration number.
pub fn set_active_configuration(&mut self, config: u8) -> Result<()>
[src]
pub fn set_active_configuration(&mut self, config: u8) -> Result<()>
Sets the device's active configuration.
pub fn unconfigure(&mut self) -> Result<()>
[src]
pub fn unconfigure(&mut self) -> Result<()>
Puts the device in an unconfigured state.
pub fn reset(&mut self) -> Result<()>
[src]
pub fn reset(&mut self) -> Result<()>
Resets the device.
pub fn kernel_driver_active(&self, iface: u8) -> Result<bool>
[src]
pub fn kernel_driver_active(&self, iface: u8) -> Result<bool>
Indicates whether the device has an attached kernel driver.
This method is not supported on all platforms.
pub fn detach_kernel_driver(&mut self, iface: u8) -> Result<()>
[src]
pub fn detach_kernel_driver(&mut self, iface: u8) -> Result<()>
Detaches an attached kernel driver from the device.
This method is not supported on all platforms.
pub fn attach_kernel_driver(&mut self, iface: u8) -> Result<()>
[src]
pub fn attach_kernel_driver(&mut self, iface: u8) -> Result<()>
Attaches a kernel driver to the device.
This method is not supported on all platforms.
pub fn claim_interface(&mut self, iface: u8) -> Result<()>
[src]
pub fn claim_interface(&mut self, iface: u8) -> Result<()>
Claims one of the device's interfaces.
An interface must be claimed before operating on it. All claimed interfaces are released when the device handle goes out of scope.
pub fn release_interface(&mut self, iface: u8) -> Result<()>
[src]
pub fn release_interface(&mut self, iface: u8) -> Result<()>
Releases a claimed interface.
pub fn set_alternate_setting(&mut self, iface: u8, setting: u8) -> Result<()>
[src]
pub fn set_alternate_setting(&mut self, iface: u8, setting: u8) -> Result<()>
Sets an interface's active setting.
pub fn read_interrupt(
&self,
endpoint: u8,
buf: &mut [u8],
timeout: Duration
) -> Result<usize>
[src]
pub fn read_interrupt(
&self,
endpoint: u8,
buf: &mut [u8],
timeout: Duration
) -> Result<usize>
Reads from an interrupt endpoint.
This function attempts to read from the interrupt endpoint with the address given by the
endpoint
parameter and fills buf
with any data received from the endpoint. The function
blocks up to the amount of time specified by timeout
.
If the return value is Ok(n)
, then buf
is populated with n
bytes of data received
from the endpoint.
Errors
If this function encounters any form of error while fulfilling the transfer request, an error variant will be returned. If an error variant is returned, no bytes were read.
The errors returned by this function include:
InvalidParam
if the endpoint is not an input endpoint.Timeout
if the transfer timed out.Pipe
if the endpoint halted.Overflow
if the device offered more data.NoDevice
if the device has been disconnected.Io
if the transfer encountered an I/O error.
pub fn write_interrupt(
&self,
endpoint: u8,
buf: &[u8],
timeout: Duration
) -> Result<usize>
[src]
pub fn write_interrupt(
&self,
endpoint: u8,
buf: &[u8],
timeout: Duration
) -> Result<usize>
Writes to an interrupt endpoint.
This function attempts to write the contents of buf
to the interrupt endpoint with the
address given by the endpoint
parameter. The function blocks up to the amount of time
specified by timeout
.
If the return value is Ok(n)
, then n
bytes of buf
were written to the endpoint.
Errors
If this function encounters any form of error while fulfilling the transfer request, an error variant will be returned. If an error variant is returned, no bytes were written.
The errors returned by this function include:
InvalidParam
if the endpoint is not an output endpoint.Timeout
if the transfer timed out.Pipe
if the endpoint halted.NoDevice
if the device has been disconnected.Io
if the transfer encountered an I/O error.
pub fn read_bulk(
&self,
endpoint: u8,
buf: &mut [u8],
timeout: Duration
) -> Result<usize>
[src]
pub fn read_bulk(
&self,
endpoint: u8,
buf: &mut [u8],
timeout: Duration
) -> Result<usize>
Reads from a bulk endpoint.
This function attempts to read from the bulk endpoint with the address given by the
endpoint
parameter and fills buf
with any data received from the endpoint. The function
blocks up to the amount of time specified by timeout
.
If the return value is Ok(n)
, then buf
is populated with n
bytes of data received
from the endpoint.
Errors
If this function encounters any form of error while fulfilling the transfer request, an error variant will be returned. If an error variant is returned, no bytes were read.
The errors returned by this function include:
InvalidParam
if the endpoint is not an input endpoint.Timeout
if the transfer timed out.Pipe
if the endpoint halted.Overflow
if the device offered more data.NoDevice
if the device has been disconnected.Io
if the transfer encountered an I/O error.
pub fn write_bulk(
&self,
endpoint: u8,
buf: &[u8],
timeout: Duration
) -> Result<usize>
[src]
pub fn write_bulk(
&self,
endpoint: u8,
buf: &[u8],
timeout: Duration
) -> Result<usize>
Writes to a bulk endpoint.
This function attempts to write the contents of buf
to the bulk endpoint with the address
given by the endpoint
parameter. The function blocks up to the amount of time specified
by timeout
.
If the return value is Ok(n)
, then n
bytes of buf
were written to the endpoint.
Errors
If this function encounters any form of error while fulfilling the transfer request, an error variant will be returned. If an error variant is returned, no bytes were written.
The errors returned by this function include:
InvalidParam
if the endpoint is not an output endpoint.Timeout
if the transfer timed out.Pipe
if the endpoint halted.NoDevice
if the device has been disconnected.Io
if the transfer encountered an I/O error.
pub fn read_control(
&self,
request_type: u8,
request: u8,
value: u16,
index: u16,
buf: &mut [u8],
timeout: Duration
) -> Result<usize>
[src]
pub fn read_control(
&self,
request_type: u8,
request: u8,
value: u16,
index: u16,
buf: &mut [u8],
timeout: Duration
) -> Result<usize>
Reads data using a control transfer.
This function attempts to read data from the device using a control transfer and fills
buf
with any data received during the transfer. The function blocks up to the amount of
time specified by timeout
.
The parameters request_type
, request
, value
, and index
specify the fields of the
control transfer setup packet (bmRequestType
, bRequest
, wValue
, and wIndex
respectively). The values for each of these parameters shall be given in host-endian byte
order. The value for the request_type
parameter can be built with the helper function,
request_type(). The meaning of the other parameters depends on the
type of control request.
If the return value is Ok(n)
, then buf
is populated with n
bytes of data.
Errors
If this function encounters any form of error while fulfilling the transfer request, an error variant will be returned. If an error variant is returned, no bytes were read.
The errors returned by this function include:
InvalidParam
ifrequest_type
does not specify a read transfer.Timeout
if the transfer timed out.Pipe
if the control request was not supported by the device.NoDevice
if the device has been disconnected.Io
if the transfer encountered an I/O error.
pub fn write_control(
&self,
request_type: u8,
request: u8,
value: u16,
index: u16,
buf: &[u8],
timeout: Duration
) -> Result<usize>
[src]
pub fn write_control(
&self,
request_type: u8,
request: u8,
value: u16,
index: u16,
buf: &[u8],
timeout: Duration
) -> Result<usize>
Writes data using a control transfer.
This function attempts to write the contents of buf
to the device using a control
transfer. The function blocks up to the amount of time specified by timeout
.
The parameters request_type
, request
, value
, and index
specify the fields of the
control transfer setup packet (bmRequestType
, bRequest
, wValue
, and wIndex
respectively). The values for each of these parameters shall be given in host-endian byte
order. The value for the request_type
parameter can be built with the helper function,
request_type(). The meaning of the other parameters depends on the
type of control request.
If the return value is Ok(n)
, then n
bytes of buf
were transfered.
Errors
If this function encounters any form of error while fulfilling the transfer request, an error variant will be returned. If an error variant is returned, no bytes were read.
The errors returned by this function include:
InvalidParam
ifrequest_type
does not specify a write transfer.Timeout
if the transfer timed out.Pipe
if the control request was not supported by the device.NoDevice
if the device has been disconnected.Io
if the transfer encountered an I/O error.
pub fn read_languages(&self, timeout: Duration) -> Result<Vec<Language>>
[src]
pub fn read_languages(&self, timeout: Duration) -> Result<Vec<Language>>
Reads the languages supported by the device's string descriptors.
This function returns a list of languages that can be used to read the device's string descriptors.
pub fn read_string_descriptor(
&self,
language: Language,
index: u8,
timeout: Duration
) -> Result<String>
[src]
pub fn read_string_descriptor(
&self,
language: Language,
index: u8,
timeout: Duration
) -> Result<String>
Reads a string descriptor from the device.
language
should be one of the languages returned from read_languages
.
pub fn read_manufacturer_string(
&self,
language: Language,
device: &DeviceDescriptor,
timeout: Duration
) -> Result<String>
[src]
pub fn read_manufacturer_string(
&self,
language: Language,
device: &DeviceDescriptor,
timeout: Duration
) -> Result<String>
Reads the device's manufacturer string descriptor.
pub fn read_product_string(
&self,
language: Language,
device: &DeviceDescriptor,
timeout: Duration
) -> Result<String>
[src]
pub fn read_product_string(
&self,
language: Language,
device: &DeviceDescriptor,
timeout: Duration
) -> Result<String>
Reads the device's product string descriptor.
pub fn read_serial_number_string(
&self,
language: Language,
device: &DeviceDescriptor,
timeout: Duration
) -> Result<String>
[src]
pub fn read_serial_number_string(
&self,
language: Language,
device: &DeviceDescriptor,
timeout: Duration
) -> Result<String>
Reads the device's serial number string descriptor.
pub fn read_configuration_string(
&self,
language: Language,
configuration: &ConfigDescriptor,
timeout: Duration
) -> Result<String>
[src]
pub fn read_configuration_string(
&self,
language: Language,
configuration: &ConfigDescriptor,
timeout: Duration
) -> Result<String>
Reads the string descriptor for a configuration's description.
pub fn read_interface_string(
&self,
language: Language,
interface: &InterfaceDescriptor,
timeout: Duration
) -> Result<String>
[src]
pub fn read_interface_string(
&self,
language: Language,
interface: &InterfaceDescriptor,
timeout: Duration
) -> Result<String>
Reads the string descriptor for a interface's description.
Trait Implementations
impl<'a> Drop for DeviceHandle<'a>
[src]
impl<'a> Drop for DeviceHandle<'a>
impl<'a> Sync for DeviceHandle<'a>
[src]
impl<'a> Sync for DeviceHandle<'a>
impl<'a> Send for DeviceHandle<'a>
[src]
impl<'a> Send for DeviceHandle<'a>
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more