Struct ft60x_rs::Device

source ·
pub struct Device { /* private fields */ }
Expand description

A D3XX device.

The Device struct represents a single D3XX device. It provides methods for interacting with the device, such as configuring and reading/writing to the device.

Implementations§

source§

impl Device

source

pub fn open(info: &DeviceInfo) -> Result<Device>

Open a device using the given device information.

source

pub fn open_with_serial_number(serial_number: &str) -> Result<Device>

Open a device using the given serial number.

source

pub unsafe fn from_handle(handle: *mut c_void) -> Device

Create a device wrapper using a raw handle

source

pub fn raw_handle(&self) -> *mut c_void

Get the raw handle to the D3XX device.

source

pub fn info(&self) -> Result<DeviceInfo>

Gets information about the device.

source

pub fn vendor_id(&self) -> Result<usize>

Get the vendor ID of the device.

source

pub fn product_id(&self) -> Result<usize>

Get the product ID of the device.

source

pub fn is_usb2(&self) -> Result<bool>

Check if the device is connected using a USB2 cable.

source

pub fn is_usb3(&self) -> Result<bool>

Check if the device is connected using a USB3 cable.

source

pub fn driver_version(&self) -> Result<Version>

Gets the D3XX kernel driver version.

source

pub fn index(&self) -> Result<usize>

Get the index of this device in the current device info list.

source

pub fn pipe_info(&self, pipe: Pipe) -> Result<PipeInfo>

Get information about a pipe.

source

pub fn write(&self, pipe: Pipe, buf: &[u8]) -> Result<usize>

Writes data to the specified pipe. This method will block until the transfer is complete, or the timeout is reached.

source

pub fn read(&self, pipe: Pipe, buf: &mut [u8]) -> Result<usize>

Reads data from the specified pipe. This method will block until the transfer is complete, or the timeout is reached.

source

pub fn flush(&self, pipe: Pipe) -> Result<()>

Discards any data cached in an IN pipe. If pipe is an OUT pipe, an InvalidParameter error is returned.

source

pub fn set_timeout(&self, pipe: Pipe, timeout: Duration) -> Result<()>

Configures a timeout for the specified endpoint. Reading and writing will timeout in the event the operation hangs for the given duration.

The new value is only valid as long as the device is open; re-opening the device will reset the timeout to the default of 5 seconds.

source

pub fn get_timeout(&self, pipe: Pipe) -> Result<Duration>

Get the timeout configured for the specified pipe.

source

pub fn set_stream_size( &self, pipe: Pipe, stream_size: Option<u32> ) -> Result<()>

Sets streaming protocol transfer for the specified pipe. This is for applications that read or write a fixed size of data to or from the device.

source

pub fn abort_transfers(&self, pipe: Pipe) -> Result<()>

Aborts all pending transfers for the given pipe.

source

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

Get the USB device descriptor.

source

pub fn power_cycle_port(self) -> Result<()>

Power cycles the device port. This causes the device to be re-enumermated by the host. Consumes the object, meaning the device must be re-opened.

Trait Implementations§

source§

impl Debug for Device

source§

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

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

impl Drop for Device

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for Device

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.