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

#1122 in Asynchronous

Download history 581/week @ 2024-05-16 578/week @ 2024-05-23 703/week @ 2024-05-30 542/week @ 2024-06-06 613/week @ 2024-06-13 651/week @ 2024-06-20 517/week @ 2024-06-27 253/week @ 2024-07-04 531/week @ 2024-07-11 662/week @ 2024-07-18 647/week @ 2024-07-25 727/week @ 2024-08-01 855/week @ 2024-08-08 648/week @ 2024-08-15 552/week @ 2024-08-22 751/week @ 2024-08-29

2,906 downloads per month
Used in 16 crates (4 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