Skip to main content

ReplayBuffer

Struct ReplayBuffer 

Source
pub struct ReplayBuffer { /* private fields */ }
Expand description

Per-stream sequencing + global bounded retention.

Implementations§

Source§

impl ReplayBuffer

Source

pub fn new(limits: BufferLimits) -> Self

Source

pub fn with_default_credit(self, credit: u32) -> Self

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn total_bytes(&self) -> usize

Source

pub fn credit(&self, key: &StreamKey) -> u32

Source

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.

Source

pub fn reset_channel_credit(&mut self, node_id: &str, channel_id: u32)

Reset credit when the node (re)OPENs a channel.

Source

pub fn enqueue( &mut self, node_id: impl Into<String>, channel_id: u32, payload: Vec<u8>, now: Instant, ) -> EnqueueOutcome

Source

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.

Source

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].

Source

pub fn oldest_seq(&self, node_id: &str, channel_id: u32) -> Option<u64>

Lowest seq still retained for the stream, if any.

Source

pub fn next_seq(&self, node_id: &str, channel_id: u32) -> u64

Highest seq assigned for the stream (whether or not still buffered).

Source

pub fn gap_before_buffer( &self, node_id: &str, channel_id: u32, after: u64, ) -> bool

True when RESUME(after=N) asks for a seq that has already left the buffer.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.