pub struct Mock<Word> { /* private fields */ }
Available on crate feature eh1 only.
Expand description

Mock serial device

The mock serial device can be loaded with expected transactions, then passed-on into a serial device user. If the expectations were not met in the specified order, the type causes a panic and describes what expectation wasn’t met.

The type is clonable so that it may be shared with a serial device user. Under the hood, both cloned mocks will share the same state, allowing your handle to eventually call done(), if desired.

Implementations§

source§

impl<Word: Clone> Mock<Word>

source

pub fn new(transactions: &[Transaction<Word>]) -> Self

Create a serial mock that will expect the provided transactions

source

pub fn update_expectations(&mut self, transactions: &[Transaction<Word>])

Update expectations on the interface

When this method is called, first it is ensured that existing expectations are all consumed by calling done() internally (if not called already). Afterwards, the new expectations are set.

source

pub fn expect<E>(&mut self, transactions: &[Transaction<Word>])

👎Deprecated since 0.10.0: The method ‘expect’ was renamed to ‘update_expectations’

Deprecated alias of update_expectations.

source

pub fn done(&mut self)

Asserts that all expectations up to this point were satisfied. Panics if there are unsatisfied expectations.

Trait Implementations§

source§

impl<Word: Clone> Clone for Mock<Word>

source§

fn clone(&self) -> Mock<Word>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<Word> ErrorType for Mock<Word>

§

type Error = ErrorKind

Error type
source§

impl<Word> Read<Word> for Mock<Word>
where Word: Copy + Clone + Debug,

source§

fn read(&mut self) -> Result<Word, Self::Error>

Reads a single word from the serial interface
source§

impl<Word> Write<Word> for Mock<Word>
where Word: PartialEq + Debug + Copy + Clone,

source§

fn write(&mut self, word: Word) -> Result<(), Self::Error>

Writes a single word to the serial interface.
source§

fn flush(&mut self) -> Result<(), Self::Error>

Ensures that none of the previously written words are still buffered.

Auto Trait Implementations§

§

impl<Word> RefUnwindSafe for Mock<Word>

§

impl<Word> Send for Mock<Word>
where Word: Send,

§

impl<Word> Sync for Mock<Word>
where Word: Send,

§

impl<Word> Unpin for Mock<Word>

§

impl<Word> UnwindSafe for Mock<Word>

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

§

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

§

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.