10 releases (1 stable)

✓ Uses Rust 2018 edition

1.0.0 Dec 17, 2019
0.3.0 Nov 19, 2019
0.2.6 Sep 25, 2019
0.1.0 Sep 15, 2019

#49 in Concurrency

Download history 2435/week @ 2019-11-07 1979/week @ 2019-11-14 2051/week @ 2019-11-21 2307/week @ 2019-11-28 3096/week @ 2019-12-05 4611/week @ 2019-12-12 3857/week @ 2019-12-19 1963/week @ 2019-12-26 3590/week @ 2020-01-02 5339/week @ 2020-01-09 4990/week @ 2020-01-16 4053/week @ 2020-01-23 5872/week @ 2020-01-30 6596/week @ 2020-02-06 6256/week @ 2020-02-13

8,179 downloads per month
Used in 57 crates (2 directly)

MIT/Apache

15KB
315 lines

broadcaster

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

lib.rs:

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_executor::block_on;
use futures_util::StreamExt;

# block_on(async {
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));
# Ok::<(), futures_channel::mpsc::SendError>(())
# }).unwrap();

Dependencies

~1MB
~17K SLoC