Struct embedded_hal_mock::eh1::serial::Transaction
source · 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,
impl<Word> Transaction<Word>where
Word: Clone,
sourcepub fn read_error(error: Error<ErrorKind>) -> Self
pub fn read_error(error: Error<ErrorKind>) -> Self
Expect a serial read that returns an error
sourcepub fn write_many<Ws>(words: Ws) -> Self
pub fn write_many<Ws>(words: Ws) -> Self
Expect a serial write that transmits the specified words
sourcepub fn write_error(word: Word, error: Error<ErrorKind>) -> Self
pub fn write_error(word: Word, error: Error<ErrorKind>) -> Self
Expect a serial write that returns an error after transmitting the specified word
sourcepub fn flush_error(error: Error<ErrorKind>) -> Self
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more