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

#914 in Asynchronous

Download history 1154/week @ 2023-10-26 898/week @ 2023-11-02 849/week @ 2023-11-09 1007/week @ 2023-11-16 1040/week @ 2023-11-23 586/week @ 2023-11-30 621/week @ 2023-12-07 1015/week @ 2023-12-14 918/week @ 2023-12-21 944/week @ 2023-12-28 872/week @ 2024-01-04 724/week @ 2024-01-11 917/week @ 2024-01-18 542/week @ 2024-01-25 566/week @ 2024-02-01 771/week @ 2024-02-08

2,886 downloads per month
Used in 17 crates (5 directly)

MIT/Apache

17KB
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_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));

Dependencies

~0.6–1.1MB
~18K SLoC