ReplayChannel
ReplayChannel
is a Rust library that lets you create a channel where messages are broadcast to all
receivers. Importantly, if a new receiver is added later, they'll get all previously sent messages
until they are caught up with the sender.
Developed by Ian Clarke for the Freenet Project.
Features
- Message Replay: New receivers are sent all previously sent messages until they are caught up with the sender.
- Multi-Receiver: Supports multiple receivers, each with its own view of the message history and real-time stream.
- Asynchronous: Designed to be used with Tokio, async-std, or any other async runtime.
Memory Usage
ReplayChannel
uses a VecDeque
to store all sent messages, so the memory usage is proportional
to the number of messages sent. Because of this the number of messages sent should be bounded.
Getting Started
To use ReplayChannel
, add it to your project's Cargo.toml
:
Usage Example
let replay_channel = new;
let sender = replay_channel.sender;
sender.send;
sender.send;
let mut receiver = replay_channel.receiver;
assert_eq!;
assert_eq!;
let mut new_receiver = replay_channel.receiver;
assert_eq!;
assert_eq!;
sender.send;
assert_eq!;
License
Available under the MIT license.