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

A serial transaction

Transactions can either be reads, writes, or flushes. A collection of transactions represent the expected operations that are performed on your serial device.

Example

use embedded_hal_mock::eh1::serial::{Mock, Transaction};

// We expect, in order,
// 1. A read that returns 0x23,
// 2. A write of [0x55, 0xAA]
// 3. A flush
let transactions = [
    Transaction::read(0x23),
    Transaction::write_many([0x55, 0xAA]),
    Transaction::flush(),
];

let mut serial = Mock::new(&transactions);

Implementations§

source§

impl<Word> Transaction<Word>
where Word: Clone,

source

pub fn read(word: Word) -> Self

Expect a serial read that returns the expected word

source

pub fn read_many<Ws>(words: Ws) -> Self
where Ws: AsRef<[Word]>,

Expect a serial read that returns the expected words

source

pub fn read_error(error: Error<ErrorKind>) -> Self

Expect a serial read that returns an error

source

pub fn write(word: Word) -> Self

Expect a serial write that transmits the specified word

source

pub fn write_many<Ws>(words: Ws) -> Self
where Ws: AsRef<[Word]>,

Expect a serial write that transmits the specified words

source

pub fn write_error(word: Word, error: Error<ErrorKind>) -> Self

Expect a serial write that returns an error after transmitting the specified word

source

pub fn flush() -> Self

Expect a caller to flush the serial buffers

source

pub fn flush_error(error: Error<ErrorKind>) -> Self

Expect a serial flush that returns an error

Auto Trait Implementations§

§

impl<Word> RefUnwindSafe for Transaction<Word>
where Word: RefUnwindSafe,

§

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

§

impl<Word> Sync for Transaction<Word>
where Word: Sync,

§

impl<Word> Unpin for Transaction<Word>
where Word: Unpin,

§

impl<Word> UnwindSafe for Transaction<Word>
where Word: UnwindSafe,

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