Struct embedded_hal_mock::i2c::Mock [−][src]
pub struct Mock<'a> { /* fields omitted */ }
Mock I²C implementation
The main idea behind this is that you set the data that will be read back by a read call in advance. Then the driver can read from the mock device, and will get exactly the data you prepared.
See the usage section in the module level docs for an example.
Methods
impl<'a> Mock<'a>
[src]
impl<'a> Mock<'a>
pub fn new() -> Self
[src]
pub fn new() -> Self
pub fn set_read_data(&mut self, data: &'a [u8])
[src]
pub fn set_read_data(&mut self, data: &'a [u8])
Set data that will be read by read()
.
pub fn get_write_data(&self) -> &[u8]
[src]
pub fn get_write_data(&self) -> &[u8]
Return the data that was written by the last write command.
pub fn get_last_address(&self) -> Option<u8>
[src]
pub fn get_last_address(&self) -> Option<u8>
Return the address that was used by the last read or write command.
Trait Implementations
impl<'a> Read for Mock<'a>
[src]
impl<'a> Read for Mock<'a>
type Error = MockError
Error type
fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error>
[src]
fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error>
Reads enough bytes from slave with address
to fill buffer
Read more
impl<'a> Write for Mock<'a>
[src]
impl<'a> Write for Mock<'a>
type Error = MockError
Error type
fn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), Self::Error>
[src]
fn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), Self::Error>
Sends bytes to slave with address addr
Read more
impl<'a> WriteRead for Mock<'a>
[src]
impl<'a> WriteRead for Mock<'a>