[][src]Struct mh_zx_driver::Sensor

pub struct Sensor<U> { /* fields omitted */ }

A struct representing sensor interface.

Implementations

impl<R, W> Sensor<UartWrapper<R, W>> where
    R: Read<u8>,
    W: Write<u8>, 
[src]

Constructs the Sensor interface from 2 'halves' of UART.

pub fn from_rx_tx(read: R, write: W) -> Sensor<UartWrapper<R, W>>[src]

impl<U> Sensor<U> where
    U: Read<u8> + Write<u8>, 
[src]

pub fn new(uart: U) -> Sensor<U>[src]

pub fn write_packet_op<'a>(
    &'a mut self,
    packet: &'a Packet
) -> impl FnMut() -> Result<(), <U as Write<u8>>::Error> + 'a
[src]

Write a packet to the device.

Returns a closure that sends a packet to the sensor. The result of this function can be used with the block!() macro from nb crate, e.g.:


let mut op = sensor.write_packet_op(commands::READ_CO2);
block!(op()).unwrap();

pub fn read_packet_op<'a>(
    &'a mut self,
    packet: &'a mut Packet
) -> impl FnMut() -> Result<(), <U as Read<u8>>::Error> + 'a
[src]

Read a packet from the device.

Returns a closure that reads a response packet from the sensor. The result of this function can be used with the block!() macro from nb crate, e.g.:


let mut packet = Default::default();
let mut op = sensor.read_packet_op(&mut packet);
block!(op()).unwrap();

Auto Trait Implementations

impl<U> Send for Sensor<U> where
    U: Send

impl<U> Sync for Sensor<U> where
    U: Sync

impl<U> Unpin for Sensor<U> where
    U: Unpin

Blanket Implementations

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

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

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

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

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

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