pub fn bounded<T>(cap: usize) -> (OverwriteSender<T>, Receiver<T>)Expand description
Creates a bounded channel with overwrite capability.
Returns a tuple of (OverwriteSender<T>, Receiver<T>) where the sender can overwrite
old messages when the channel reaches capacity, and the receiver is a standard flume receiver.
§Arguments
cap- The maximum number of messages the channel can hold
§Returns
A tuple containing:
OverwriteSender<T>- A sender that can overwrite old messages when at capacityReceiver<T>- A standard flume receiver for reading messages
§Examples
use flume_overwrite::bounded;
let (sender, receiver) = bounded(2);
sender.send_overwrite("hello").unwrap();
sender.send_overwrite("world").unwrap();
assert_eq!(receiver.recv().unwrap(), "hello");
assert_eq!(receiver.recv().unwrap(), "world");