Crate barrage

Source
Expand description

Barrage - an asynchronous broadcast channel. Each message sent will be received by every receiver. When the channel reaches its cap, send operations will block, wait, or fail (depending on which type of send was chosen). Cloned receivers will only receive messages sent after they are cloned.

§Example


let (tx, rx1) = barrage::unbounded();
let rx2 = rx1.clone();
tx.send("Hello!");
let rx3 = rx1.clone();
assert_eq!(rx1.recv(), Ok("Hello!"));
assert_eq!(rx2.recv(), Ok("Hello!"));
assert_eq!(rx3.try_recv(), Ok(None));

Structs§

Disconnected
All senders have disconnected from the channel and there are no more messages waiting.
Receiver
The receiver side of the channel. This will receive every message broadcast.
RecvFut
The future representing an asynchronous receive operation.
SendError
SendFut
The future representing an asynchronous broadcast operation.
Sender
The broadcaster side of the channel.
SharedReceiver
A shared receiver is similar to a receiver, but it shares a mailbox with the other shared receivers from which it originates (was cloned from). Thus, only one shared receiver with the same mailbox will receive a broadcast.

Enums§

TrySendError

Functions§

bounded
Create a bounded channel of the given capacity.
new
Create a new channel with the given capacity. If None is passed, it will be unbounded.
unbounded
Create an unbounded channel.