Struct MockDevice

Source
pub struct MockDevice { /* private fields */ }
Expand description

A I2CMasterDevice implementation that exists solely for testing. The MockDevice delegates writes and reades to the supplied callback functions/data that are used in tests for checking the correct device communication.

Implementations§

Source§

impl MockDevice

Source

pub fn new_write_only(write_block_cb: WriteCb) -> MockDevice

Source

pub fn new_read_only(read_block_data: Vec<u8>) -> MockDevice

Source

pub fn new(write_block_cb: WriteCb, read_block_data: Vec<u8>) -> MockDevice

Trait Implementations§

Source§

impl I2CMasterDevice for MockDevice

Source§

fn write_block(&mut self, register: u8, values: &[u8]) -> Result<()>

Source§

fn read_block(&mut self, _register: u8, _len: u8) -> Result<Vec<u8>>

Auto Trait Implementations§

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

Source§

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

Source§

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.