ArbitraryI2c

Struct ArbitraryI2c 

Source
pub struct ArbitraryI2c<T> { /* private fields */ }
Expand description

Creates a fuzzed i2c driver, this type is intended to be constructed the arbitrary crate e.g.

use arbitrary::{Arbitrary, Unstructured};
use embedded_hal_fuzz::i2c::ArbitraryI2c;
use embedded_hal::i2c::{SevenBitAddress, TenBitAddress};
let raw_fuzzed_data = &[1u8, 2, 3, 4, 5][..];
let mut unstructured = Unstructured::new(raw_fuzzed_data);
let seven_bit_spi_bus = ArbitraryI2c::<SevenBitAddress>::arbitrary(&mut unstructured);
let ten_bit_spi_bus = ArbitraryI2c::<TenBitAddress>::arbitrary(&mut unstructured);

Trait Implementations§

Source§

impl<'arbitrary, T: Arbitrary<'arbitrary>> Arbitrary<'arbitrary> for ArbitraryI2c<T>

Source§

fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl<T: Debug> Debug for ArbitraryI2c<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> ErrorType for ArbitraryI2c<T>

Source§

type Error = Error

Error type
Source§

impl I2c<u16> for ArbitraryI2c<TenBitAddress>

Source§

fn transaction( &mut self, _address: u16, operations: &mut [Operation<'_>], ) -> Result<(), Self::Error>

Execute the provided operations on the I2C bus. Read more
Source§

fn read(&mut self, address: A, read: &mut [u8]) -> Result<(), Self::Error>

Reads enough bytes from slave with address to fill read. Read more
Source§

fn write(&mut self, address: A, write: &[u8]) -> Result<(), Self::Error>

Writes bytes to slave with address address. Read more
Source§

fn write_read( &mut self, address: A, write: &[u8], read: &mut [u8], ) -> Result<(), Self::Error>

Writes bytes to slave with address address and then reads enough bytes to fill read in a single transaction. Read more
Source§

impl I2c for ArbitraryI2c<SevenBitAddress>

Source§

fn transaction( &mut self, _address: u8, operations: &mut [Operation<'_>], ) -> Result<(), Self::Error>

Execute the provided operations on the I2C bus. Read more
Source§

fn read(&mut self, address: A, read: &mut [u8]) -> Result<(), Self::Error>

Reads enough bytes from slave with address to fill read. Read more
Source§

fn write(&mut self, address: A, write: &[u8]) -> Result<(), Self::Error>

Writes bytes to slave with address address. Read more
Source§

fn write_read( &mut self, address: A, write: &[u8], read: &mut [u8], ) -> Result<(), Self::Error>

Writes bytes to slave with address address and then reads enough bytes to fill read in a single transaction. Read more

Auto Trait Implementations§

§

impl<T> Freeze for ArbitraryI2c<T>

§

impl<T> RefUnwindSafe for ArbitraryI2c<T>
where T: RefUnwindSafe,

§

impl<T> Send for ArbitraryI2c<T>
where T: Send,

§

impl<T> Sync for ArbitraryI2c<T>
where T: Sync,

§

impl<T> Unpin for ArbitraryI2c<T>
where T: Unpin,

§

impl<T> UnwindSafe for ArbitraryI2c<T>
where T: 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>,

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.