Skip to main content

FakeTransport

Struct FakeTransport 

Source
pub struct FakeTransport { /* private fields */ }
Available on crate feature fake-transport only.
Expand description

Thread-safe fake USB device for tests (crate::Transport implementor).

Implementations§

Source§

impl FakeTransport

Source

pub fn new() -> Self

Source

pub fn cdc_single_iface() -> Self

Single CDC ACM interface with bulk IN/OUT endpoints (castrated single-iface layout).

Source

pub fn ftdi_ft232r() -> Self

FT232R-shaped single-interface layout (0403:6001).

Source

pub fn ftdi_ft2232() -> Self

Source

pub fn cp2102() -> Self

Source

pub fn cp2105() -> Self

Source

pub fn ch340_dual_iface() -> Self

Source

pub fn pl2303_hx() -> Self

Source

pub fn pl2303_hxn() -> Self

Source

pub fn pl2303_type01() -> Self

Source

pub fn pl2303_ta() -> Self

Source

pub fn cdc_iad() -> Self

Source

pub fn cdc_multi() -> Self

Source

pub fn gsm_modem() -> Self

Source

pub fn chrome_ccd_3port() -> Self

Source

pub fn recorded_bulk_out(&self) -> Vec<RecordedBulkOut>

Source

pub fn push_rx(&self, data: &[u8])

Source

pub fn push_interrupt_in(&self, data: &[u8])

Source

pub fn take_tx(&self) -> Vec<u8>

Drain and return bytes written to bulk OUT (test asserts).

Source

pub fn recorded_controls(&self) -> Vec<RecordedControl>

Snapshot recorded control transfers.

Source

pub fn clear_recorded(&self)

Source

pub fn claimed_interfaces(&self) -> Vec<u8>

Source

pub fn script_control_in_response(&self, data: Vec<u8>)

Queue the next control_in response payload (FIFO).

Source

pub fn inject_bulk_read_error(&self, msg: impl Into<String>)

Source

pub fn set_interfaces(&self, interfaces: Vec<InterfaceInfo>)

Source

pub fn configure_endpoints(&self, layout: &[(u8, Vec<EndpointInfo>)])

Source

pub fn set_raw_descriptors(&self, raw: Vec<u8>)

Source

pub fn set_vendor_product(&self, vendor_id: u16, product_id: u16)

Source

pub fn patch_device_descriptor(&self, patch: impl FnMut(&mut [u8; 18]))

Trait Implementations§

Source§

impl Clone for FakeTransport

Source§

fn clone(&self) -> FakeTransport

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FakeTransport

Source§

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

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

impl Default for FakeTransport

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Transport for FakeTransport

Source§

fn raw_device_descriptor(&self) -> [u8; 18]

Source§

fn raw_descriptors(&self) -> Vec<u8>

Source§

fn device_class(&self) -> u8

Source§

fn interfaces(&self) -> Vec<InterfaceInfo>

Source§

fn endpoints(&self, interface: u8) -> Vec<EndpointInfo>

Source§

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

Source§

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

Source§

fn control_out(&self, req: &ControlRequest) -> Result<usize>

Source§

fn control_in(&self, req: &ControlRequest) -> Result<Vec<u8>>

Source§

fn open_bulk_in( &self, endpoint: u8, _max_packet_size: u16, ) -> Result<Box<dyn BulkIn>>

Source§

fn open_bulk_out( &self, endpoint: u8, _max_packet_size: u16, ) -> Result<Box<dyn BulkOut>>

Source§

fn open_interrupt_in( &self, endpoint: u8, _max_packet_size: u16, ) -> Result<Box<dyn BulkIn>>

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
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.