pub trait AsyncReceive<'a, I, E> {
    type Output: Future<Output = Result<(usize, I), AsyncError<E>>>;

    fn async_receive(
        &'a mut self,
        buff: &'a mut [u8],
        rx_options: AsyncOptions
    ) -> Result<Self::Output, E>; }
Expand description

Async transmit function implemented over radio::Transmit and radio::Power using the provided AsyncOptions

extern crate async_std;
use async_std::task;

use radio::nonblocking::{AsyncReceive, AsyncOptions};

let data = [0xaa, 0xbb];
let info = BasicInfo::new(-81, 0);


// Setup buffer and receive info
let mut buff = [0u8; 128];
let mut i = BasicInfo::new(0, 0);

let (n, i) = task::block_on(async {
    // Receive using a future
    radio.async_receive(&mut buff, AsyncOptions::default())?.await
})?;

assert_eq!(n, data.len());
assert_eq!(&buff[..data.len()], &data);


Ok::<(), anyhow::Error>(())

AsyncReceive trait support futures-based polling on receive

Required Associated Types

Required Methods

Implementors

Generic implementation of AsyncReceive for all Receive capable radio devices