[][src]Trait radio::nonblocking::AsyncReceive

pub trait AsyncReceive<I, E> {
    fn async_receive<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        info: &'life1 mut I,
        buff: &'life2 mut [u8],
        rx_options: AsyncOptions
    ) -> Pin<Box<dyn Future<Output = Result<usize, E>> + Send + 'async_trait>>
    where
        E: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
; }

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);

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

    // Receive using a future
    let res = radio.async_receive(&mut i, &mut buff, AsyncOptions::default()).await;
    
    assert_eq!(res, Ok(data.len()));
    assert_eq!(&buff[..data.len()], &data);
});

Required methods

fn async_receive<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 mut self,
    info: &'life1 mut I,
    buff: &'life2 mut [u8],
    rx_options: AsyncOptions
) -> Pin<Box<dyn Future<Output = Result<usize, E>> + Send + 'async_trait>> where
    E: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 

Loading content...

Implementors

impl<T, I, E> AsyncReceive<I, E> for T where
    T: Receive<Error = E, Info = I> + Send,
    I: Debug + Send,
    E: Debug + Send + Unpin
[src]

Loading content...