pub struct ReplayBuffer { /* private fields */ }Expand description
Per-stream sequencing + global bounded retention.
Implementations§
Source§impl ReplayBuffer
impl ReplayBuffer
pub fn new(limits: BufferLimits) -> Self
pub fn with_default_credit(self, credit: u32) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn total_bytes(&self) -> usize
pub fn credit(&self, key: &StreamKey) -> u32
Sourcepub fn ensure_handshake_credit(&mut self, node_id: &str, channel_id: u32)
pub fn ensure_handshake_credit(&mut self, node_id: &str, channel_id: u32)
A fresh OPEN / Noise handshake must not be refused because an earlier burst spent the stream’s credit. Restore default credit and drop the oldest buffered events on this stream until a small frame fits.
Sourcepub fn reset_channel_credit(&mut self, node_id: &str, channel_id: u32)
pub fn reset_channel_credit(&mut self, node_id: &str, channel_id: u32)
Reset credit when the node (re)OPENs a channel.
pub fn enqueue( &mut self, node_id: impl Into<String>, channel_id: u32, payload: Vec<u8>, now: Instant, ) -> EnqueueOutcome
Sourcepub fn ack(&mut self, node_id: &str, channel_id: u32, seq: u64)
pub fn ack(&mut self, node_id: &str, channel_id: u32, seq: u64)
Core ACK: drop events with seq <= ack for that stream; restore credit.
Sourcepub fn events_after(
&self,
node_id: &str,
channel_id: u32,
after: u64,
) -> Vec<BufferedEvent>
pub fn events_after( &self, node_id: &str, channel_id: u32, after: u64, ) -> Vec<BufferedEvent>
Global ACK used when core drains a single combined stream and acks by global order.
Here we treat seq as the highest seq observed in the drain for a given stream key
carried in the envelope; callers should use [ack].
Sourcepub fn oldest_seq(&self, node_id: &str, channel_id: u32) -> Option<u64>
pub fn oldest_seq(&self, node_id: &str, channel_id: u32) -> Option<u64>
Lowest seq still retained for the stream, if any.
Auto Trait Implementations§
impl Freeze for ReplayBuffer
impl RefUnwindSafe for ReplayBuffer
impl Send for ReplayBuffer
impl Sync for ReplayBuffer
impl Unpin for ReplayBuffer
impl UnsafeUnpin for ReplayBuffer
impl UnwindSafe for ReplayBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more