[][src]Struct embedded_hal_mock::serial::Mock

pub struct Mock<Word> { /* fields omitted */ }

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

impl<Word: Clone> Mock<Word>[src]

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

Create a serial mock that will expect the provided transactions

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

Set expectations on the interface

This is a list of transactions to be executed in order. Note that setting this will overwrite any existing expectations

pub fn done(&mut self)[src]

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

Trait Implementations

impl<Word: Clone> Clone for Mock<Word>[src]

impl<Word> Default<Word> for Mock<Word> where
    Word: PartialEq + Debug + Clone
[src]

impl<Word> Read<Word> for Mock<Word> where
    Word: Clone + Debug
[src]

type Error = MockError

Read error

impl<Word> Write<Word> for Mock<Word> where
    Word: PartialEq + Debug + Clone
[src]

type Error = MockError

Write error

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

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

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

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

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

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.

impl<S, Word> Write<Word> for S where
    S: Default<Word>,
    Word: Clone
[src]

type Error = <S as Write<Word>>::Error

The type of error that can occur when writing