[][src]Struct embedded_hal_spy::Spy

pub struct Spy<T, F> where
    F: Fn(DataWord), 
{ /* fields omitted */ }

embedded hal spy implemnets call backs for used traits

Intended use is chaining over an existing embedded_hal implementation sniffing all the data. Useful when preparing for a refacforing and want to collect actual data for unit test case.

Blocking SPI API hal::blocking::spi::Transfer will return DataWord::First at start of transfer, all data sent in DataWord::Byte(u8) DataWord::Response to indicate where transmit ends and response begins all recived bytes in DataWord::Byte(u8) ending with DataWord::Last

Usage:

   extern crate embedded_hal_spy;
   use embedded_hal_spy::DataWord;

   let mut spix = embedded_hal_spy::new(spi,
            |w|{
                match w {
                    DataWord::First => {
                        print!("data = [");
                    },
                    DataWord::Last =>  {println!("],"); },
                    DataWord::Response =>  { print!("],\r\n       ["); },

                    DataWord::Byte(num) => {
                        print!("{:x},",num);
                        },
                    _other => {},
                }
            }
     );

Trait Implementations

impl<T, F> Transfer<u8> for Spy<T, F> where
    T: Transfer<u8>,
    F: Fn(DataWord), 
[src]

type Error = T::Error

Error type

fn transfer<'w>(&mut self, words: &'w mut [u8]) -> Result<&'w [u8], Self::Error>[src]

Sends Word to the slave. Returns the Word received from the slave

impl<T, F> Write<u8> for Spy<T, F> where
    T: Write<u8>,
    F: Fn(DataWord), 
[src]

Blocking write

type Error = T::Error

Error type

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

Sends words to the slave, ignoring all the incoming words

impl<T, F> OutputPin for Spy<T, F> where
    T: OutputPin,
    F: Fn(DataWord), 
[src]

Digital OutputPin

type Error = T::Error

Error type

impl<T, F> StatefulOutputPin for Spy<T, F> where
    T: StatefulOutputPin,
    F: Fn(DataWord), 
[src]

impl<T, F> ToggleableOutputPin for Spy<T, F> where
    T: ToggleableOutputPin,
    F: Fn(DataWord), 
[src]

type Error = T::Error

Error type

impl<T, F> InputPin for Spy<T, F> where
    T: InputPin,
    F: Fn(DataWord), 
[src]

Digital InputPin

type Error = T::Error

Error type

impl<T, F> FullDuplex<u8> for Spy<T, F> where
    T: FullDuplex<u8>,
    F: Fn(DataWord), 
[src]

FullDuplex will return every data sent and read in DataWord::Byte(u8)

type Error = T::Error

An enumeration of SPI errors

Auto Trait Implementations

impl<T, F> Unpin for Spy<T, F> where
    F: Unpin,
    T: Unpin

impl<T, F> Send for Spy<T, F> where
    F: Send,
    T: Send

impl<T, F> !Sync for Spy<T, F>

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<W, S> Transfer<W> for S where
    S: Default<W>,
    W: Clone
[src]

type Error = <S as FullDuplex<W>>::Error

Error type

impl<W, S> Write<W> for S where
    S: Default<W>,
    W: Clone
[src]

type Error = <S as FullDuplex<W>>::Error

Error type

impl<T> OutputPin for T where
    T: OutputPin
[src]

type Error = ()

Error type

impl<T> StatefulOutputPin for T where
    T: StatefulOutputPin + OutputPin
[src]

impl<P> ToggleableOutputPin for P where
    P: Default
[src]

type Error = <P as OutputPin>::Error

Error type

fn toggle(&mut self) -> Result<(), <P as ToggleableOutputPin>::Error>[src]

Toggle pin output

impl<T> InputPin for T where
    T: InputPin
[src]

type Error = ()

Error type