Struct embedded_hal_mock::eh1::serial::Mock
source · pub struct Mock<Word> { /* private fields */ }
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>
impl<Word: Clone> Mock<Word>
sourcepub fn new(transactions: &[Transaction<Word>]) -> Self
pub fn new(transactions: &[Transaction<Word>]) -> Self
Create a serial mock that will expect the provided transactions
sourcepub fn update_expectations(&mut self, transactions: &[Transaction<Word>])
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.
sourcepub fn expect<E>(&mut self, transactions: &[Transaction<Word>])
👎Deprecated since 0.10.0: The method ‘expect’ was renamed to ‘update_expectations’
pub fn expect<E>(&mut self, transactions: &[Transaction<Word>])
Deprecated alias of update_expectations
.