10 releases (1 stable)

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

#168 in Concurrency

Download history 1718/week @ 2021-06-26 1242/week @ 2021-07-03 1291/week @ 2021-07-10 1293/week @ 2021-07-17 1083/week @ 2021-07-24 1209/week @ 2021-07-31 1087/week @ 2021-08-07 1014/week @ 2021-08-14 1240/week @ 2021-08-21 992/week @ 2021-08-28 449/week @ 2021-09-04 982/week @ 2021-09-11 481/week @ 2021-09-18 533/week @ 2021-09-25 559/week @ 2021-10-02 546/week @ 2021-10-09

4,186 downloads per month
Used in 13 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

~0.6–1MB
~18K SLoC