channel-async

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

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:

toml [dependencies] channel-async = "0.3.0-alpha.5"

Next, add this to your crate:

```rust use futures::{FutureExt, TryFutureExt};

[tokio::main]

async fn runchannels() { let (tx, rx) = channelasync::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.