channel-async

Crates.iochannel-async
lib.rschannel-async
version0.3.0-deprecated
sourcesrc
created_at2019-08-14 18:00:19.682491
updated_at2019-11-15 17:36:36.522843
descriptionAsync/Stream Extensions for crossbeam-channel
homepage
repositoryhttps://github.com/dbcfd/channel-async
max_upload_size
id156825
size17,941
Danny Browning (dbcfd)

documentation

https://docs.rs/channel-async/

README

channel-async

build status crates.io version docs.rs docs MIT licensed

  • This crate is no longer maintained *

Due to interactions between crossbeam and tokio, it is recommended that you use the channels in async-std

Async/stream extensions to crossbeam-channel on top of Futures 0.3 Stream. It is primarily intended for usage with Tokio.

Documentation

Usage

First, add this to your Cargo.toml:

[dependencies]
channel-async = "0.3.0-alpha.8"

Next, add this to your crate:

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

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in tls-async by you, shall be licensed as MIT, without any additional terms or conditions.

Commit count: 36

cargo fmt