Crates.io | broadcaster |
lib.rs | broadcaster |
version | 1.0.0 |
source | src |
created_at | 2019-09-15 20:43:02.429914 |
updated_at | 2019-12-17 16:53:45.430946 |
description | Broadcasting futures mpmc channel |
homepage | https://github.com/leo60228/broadcaster |
repository | https://github.com/leo60228/broadcaster |
max_upload_size | |
id | 164944 |
size | 16,118 |
broadcaster provides a wrapper for any Stream and Sink implementing the mpsc pattern to enable broadcasting items. This means that any item sent will be received by every receiver, not just the first to check (like most mpmc streams). As an example:
use broadcaster::BroadcastChannel;
use futures_util::StreamExt;
let mut chan = BroadcastChannel::new();
chan.send(&5i32).await?;
assert_eq!(chan.next().await, Some(5));
let mut chan2 = chan.clone();
chan2.send(&6i32).await?;
assert_eq!(chan.next().await, Some(6));
assert_eq!(chan2.next().await, Some(6));