Struct usbapi::os::linux::usbfs::UsbFs[][src]

pub struct UsbFs { /* fields omitted */ }

Implementations

impl UsbFs[src]

pub fn from_device(device: &UsbDevice) -> Result<UsbFs>[src]

pub fn from_bus_device_read_only(bus: u8, dev: u8) -> Result<UsbFs>[src]

This is used when read file descriptor strings.

pub fn from_bus_device(bus: u8, dev: u8) -> Result<UsbFs>[src]

pub fn reset(&mut self) -> Result<()>[src]

pub fn clear_halt(&mut self, ep: u8) -> Result<()>[src]

pub fn handle(&self) -> &File[src]

pub fn descriptors(&mut self) -> &Option<UsbDevice>[src]

pub fn capabilities(&mut self) -> Result<u32>[src]

pub fn async_response(&mut self) -> Result<TransferKind>[src]

Returns latest transmitted async result or an error. Example:

let mut urb = usb.new_bulk(1, 64);
// poll then
let urb = usb.async_response()
match transfer {
   Ok(transfer) => { // do stuff }
   Err(e) if e.kind() == ErrorKind::WouldBlock => {},
   Err(e) => { return Err(e); }
}

The returned Transfer can be reused after call transfer.flush()

pub fn async_response_all(&mut self) -> Result<usize>[src]

Read all URB responses if there are any pending and store it in transfers Should be called after mio poll if there is any pending usb_submit’s. The TransferKind is stored in transfers and can be read using collect_responses()

Example usage:

usb.submit_bulk(bulk);
poll.poll(&mut events, Duration::from_secs(1))?;
if !events.is_empty() {
    usb.async_response_all()?;
    for transfer in usb.collect_responses() { // Do stuff }
}

pub fn collect_responses(&mut self) -> Vec<TransferKind>[src]

Take all bulk/control responses

pub fn claim_interface(&mut self, interface: u32) -> Result<()>[src]

Claim interface

  • the interface number to claim

Examples

Basic usage:

usb.claim_interface(1)

pub fn set_interface(&mut self, interface: u32, alt_setting: u32) -> Result<()>[src]

pub fn release_interface(&self, interface: u32) -> Result<()>[src]

Release interface

  • the interface number to claim

Examples

Basic usage:

usb.release_interface(1)

pub fn bulk_read(
    &self,
    ep: u8,
    mem: &mut [u8],
    timeout: TimeoutMillis
) -> Result<u32>
[src]

Blocked bulk read Consider use @async_transfer() instead.

pub fn bulk_write(
    &self,
    ep: u8,
    mem: &[u8],
    timeout: TimeoutMillis
) -> Result<u32>
[src]

Blocked bulk write consider use @async_transfer() instead

pub fn get_descriptor_string(&mut self, id: u8) -> Result<String>[src]

Get descriptor string with id for default interface

pub fn get_descriptor_string_iface(
    &mut self,
    iface: u16,
    id: u8
) -> Result<String>
[src]

Get descriptor string with id for interface

pub fn submit_bulk(&mut self, bulk: BulkTransfer) -> Result<i32>[src]

Submit a new bulk transfer this will not block. One shall call mio poll and async_response(_all) after this call to get the transfer back Note that if the transfer is reused the user must call flush() and fill it with data before submit_bulk. Example:

bulk_out.flush()?;
bulk.write_all(&b"HELLO\n")?;
usb.submit_bulk(bulk);
// poll
resp = usb.async_response();
match resp { // do stuff }

pub fn submit_control(&mut self, control: ControlTransfer) -> Result<i32>[src]

Submit a new control transfer this will not block. One shall call mio poll and async_response(_all) after this call to get the transfer back Note that if the transfer is reused the user must call flush() before pass it to submit_control.

pub fn control_async_wait(
    &mut self,
    ctrl: ControlTransfer,
    timeout_ms: TimeoutMillis
) -> Result<ControlTransfer>
[src]

Wait for control response up to timeout ms. If it find other transfers those are stored in transfers and can be read using responses()

Trait Implementations

impl Drop for UsbFs[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

impl UsbCoreDriver for UsbFs[src]

fn new_bulk_in(
    &mut self,
    ep: u8,
    buffer_capacity: usize
) -> Result<BulkTransfer>
[src]

fn new_bulk_out(
    &mut self,
    ep: u8,
    buffer_capacity: usize
) -> Result<BulkTransfer>
[src]

fn new_control(
    &mut self,
    request_type: u8,
    request: u8,
    value: u16,
    index: u16,
    length: u16
) -> Result<ControlTransfer>
[src]

fn new_control_out(
    &mut self,
    request_type: u8,
    request: u8,
    value: u16,
    index: u16,
    buffer: &[u8]
) -> Result<ControlTransfer>
[src]

fn new_control_in(
    &mut self,
    request_type: u8,
    request: u8,
    value: u16,
    index: u16,
    length: u16
) -> Result<ControlTransfer>
[src]

fn new_control_nodata(
    &mut self,
    request_type: u8,
    request: u8,
    value: u16,
    index: u16
) -> Result<ControlTransfer>
[src]

Auto Trait Implementations

impl !RefUnwindSafe for UsbFs

impl !Send for UsbFs

impl !Sync for UsbFs

impl Unpin for UsbFs

impl !UnwindSafe for UsbFs

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.