Struct usb_util::device::Device

source ·
pub struct Device {
    fd: Arc<File>,
    device_descriptor_tree: DeviceDescriptorTree,
    dma_buffer: Option<ManagedDmaBuffer>,
}
Expand description

Device represents a USB device.

Fields§

§fd: Arc<File>§device_descriptor_tree: DeviceDescriptorTree§dma_buffer: Option<ManagedDmaBuffer>

Implementations§

source§

impl Device

source

pub fn new(fd: File) -> Result<Self>

Create a new Device from a file descriptor. fd should be a file in usbdevfs (e.g. /dev/bus/usb/001/002).

source

pub fn fd(&self) -> Arc<File>

source

unsafe fn ioctl(&self, nr: IoctlNr) -> Result<i32>

source

unsafe fn ioctl_with_ref<T>(&self, nr: IoctlNr, arg: &T) -> Result<i32>

source

unsafe fn ioctl_with_mut_ref<T>(&self, nr: IoctlNr, arg: &mut T) -> Result<i32>

source

unsafe fn ioctl_with_mut_ptr<T>(&self, nr: IoctlNr, arg: *mut T) -> Result<i32>

source

pub fn reserve_dma_buffer( &mut self, size: usize ) -> Result<Weak<Mutex<DmaBuffer>>>

source

pub fn release_dma_buffer( &mut self, dmabuf: Weak<Mutex<DmaBuffer>> ) -> Result<()>

source

pub fn submit_transfer(&mut self, transfer: Transfer) -> Result<TransferHandle>

Submit a transfer to the device. The transfer will be processed asynchronously by the device. Call poll_transfers() on this device to check for completed transfers.

source

pub fn poll_transfers(&mut self) -> Result<()>

Check for completed asynchronous transfers submitted via submit_transfer(). The callback for each completed transfer will be called.

source

pub fn reset(&self) -> Result<()>

Perform a USB port reset to reinitialize a device.

source

pub fn claim_interface(&self, interface_number: u8) -> Result<()>

Claim an interface on this device.

source

pub fn release_interface(&self, interface_number: u8) -> Result<()>

Release an interface previously claimed with claim_interface().

source

pub fn set_interface_alt_setting( &self, interface_number: u8, alternative_setting: u8 ) -> Result<()>

Activate an alternate setting for an interface.

source

pub fn set_active_configuration(&mut self, config: u8) -> Result<()>

Set active configuration for this device.

source

pub fn get_device_descriptor(&self) -> Result<DeviceDescriptor>

Get the device descriptor of this device.

source

pub fn get_device_descriptor_tree(&self) -> &DeviceDescriptorTree

source

pub fn get_config_descriptor(&self, config: u8) -> Result<ConfigDescriptorTree>

Get active config descriptor of this device.

source

pub fn get_config_descriptor_by_index( &self, config_index: u8 ) -> Result<ConfigDescriptorTree>

Get a configuration descriptor by its index within the list of descriptors returned by the device.

source

pub fn get_active_configuration(&self) -> Result<u8>

Get bConfigurationValue of the currently active configuration.

source

pub fn get_num_configurations(&self) -> u8

Get the total number of configurations for this device.

source

pub fn clear_halt(&self, ep_addr: u8) -> Result<()>

Clear the halt/stall condition for an endpoint.

source

pub fn get_speed(&self) -> Result<Option<DeviceSpeed>>

Get speed of this device.

source

pub fn alloc_streams(&self, ep: u8, num_streams: u16) -> Result<()>

Allocate streams for the endpoint

source

pub fn free_streams(&self, ep: u8) -> Result<()>

Free streams for the endpoint

Trait Implementations§

source§

impl AsRawDescriptor for Device

source§

fn as_raw_descriptor(&self) -> RawDescriptor

Returns the underlying raw descriptor. 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
§

impl<T> AsRawDescriptors for T
where T: AsRawDescriptor,

§

fn as_raw_descriptors(&self) -> Vec<i32>

Returns the underlying raw descriptors. 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>,

§

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.