Struct BusLogger

Source
pub struct BusLogger<W: Write, T>(/* private fields */);
Expand description

A wrapper around an embedded_hal bus peripheral that traces each read and write call and prints the raw bytes that were sent or received. It will also pretty-print the error result if the underlying request failed.

Currently, this requires that the error type of the underlying peripheral implements std::fmt::Debug, which most of them seem to do.

Implementations§

Source§

impl<W: Write, T> BusLogger<W, T>

Source

pub fn new(w: W, t: T) -> BusLogger<W, T>

Trait Implementations§

Source§

impl<W: Write, T: Read> Read for BusLogger<W, T>
where <T as Read>::Error: Debug,

Source§

type Error = <T as Read>::Error

Error type
Source§

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

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

impl<W: Write, T: Write> Write for BusLogger<W, T>
where <T as Write>::Error: Debug,

Source§

type Error = <T as Write>::Error

Error type
Source§

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

Writes bytes to slave with address address Read more
Source§

impl<W: Write, T: WriteRead> WriteRead for BusLogger<W, T>
where <T as WriteRead>::Error: Debug,

Source§

type Error = <T as WriteRead>::Error

Error type
Source§

fn write_read( &mut self, address: u8, bytes: &[u8], buffer: &mut [u8], ) -> Result<(), Self::Error>

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

Auto Trait Implementations§

§

impl<W, T> Freeze for BusLogger<W, T>
where W: Freeze, T: Freeze,

§

impl<W, T> RefUnwindSafe for BusLogger<W, T>

§

impl<W, T> Send for BusLogger<W, T>
where W: Send, T: Send,

§

impl<W, T> Sync for BusLogger<W, T>
where W: Sync, T: Sync,

§

impl<W, T> Unpin for BusLogger<W, T>
where W: Unpin, T: Unpin,

§

impl<W, T> UnwindSafe for BusLogger<W, T>
where W: UnwindSafe, 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.