Skip to main content

DataPhase

Enum DataPhase 

Source
pub enum DataPhase<'a> {
    In(&'a mut [u8]),
    Out(&'a [u8]),
    None,
}
Expand description

The data phase of a USB control-endpoint transaction

A transaction on a control endpoint involves one of:

  • IN (data transferred from device to host)
  • OUT (data transferred from host to device)
  • neither (the Setup packet contains all the relevant data)

See USB 2.0 section 8.5.3 and fiture 8-37.

Variants§

§

In(&'a mut [u8])

IN transaction (device-to-host)

§

Out(&'a [u8])

OUT transaction (host-to-device)

§

None

No data phase in control transaction

Implementations§

Source§

impl DataPhase<'_>

Source

pub fn is_in(&self) -> bool

Is this DataPhase an IN variant?

Source

pub fn is_out(&self) -> bool

Is this DataPhase an OUT variant?

Source

pub fn is_none(&self) -> bool

Is this DataPhase a no-data variant?

Source

pub fn in_with<F: FnOnce(&mut [u8])>(&mut self, f: F)

If this DataPhase is an IN variant, call the supplied function on the received data

Trait Implementations§

Source§

impl<'a> Debug for DataPhase<'a>

Source§

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

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

impl<'a> PartialEq for DataPhase<'a>

Source§

fn eq(&self, other: &DataPhase<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for DataPhase<'a>

Source§

impl<'a> StructuralPartialEq for DataPhase<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for DataPhase<'a>

§

impl<'a> RefUnwindSafe for DataPhase<'a>

§

impl<'a> Send for DataPhase<'a>

§

impl<'a> Sync for DataPhase<'a>

§

impl<'a> Unpin for DataPhase<'a>

§

impl<'a> UnsafeUnpin for DataPhase<'a>

§

impl<'a> !UnwindSafe for DataPhase<'a>

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

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

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>,

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.