[][src]Crate channel_async

#channel-async

Async/stream extensions for crossbeam-channel

use futures::{FutureExt, TryFutureExt};

#[tokio::main]
async fn run_channels() {
   let (tx, rx) = channel_async::unbounded(Duration::from_millis(100));

   let send_fut = async move {
       for i in 1..100 {
           tx.send(i).await.expect("Failed to send");
       }
   };

   tokio::spawn(send_fut);

   let recv_fut = async move {
     let rcvd: Vec<_> = rx.collect().await;
     rcvd
   };

   let rcvd = recv_fut.await;

   println!("Received {} messages", rcvd.len());
}

Structs

Receiver
Sender

Enums

Error

Functions

bounded
unbounded