Trait MessageBuffer

pub trait MessageBuffer<T>: Send + Sync
where T: Send + Sync,
{ // Required methods fn push(&mut self, message: T) -> Result<(), NerveError>; fn pop(&mut self) -> Result<Option<T>, NerveError>; fn peek(&self) -> Result<Option<&T>, NerveError>; fn len(&self) -> usize; fn is_empty(&self) -> bool; fn is_full(&self) -> bool; fn capacity(&self) -> usize; fn utilization(&self) -> f64; fn clear(&mut self) -> Result<usize, NerveError>; }
Expand description

Message buffer interface

Required Methods§

fn push(&mut self, message: T) -> Result<(), NerveError>

Push a message to the buffer

fn pop(&mut self) -> Result<Option<T>, NerveError>

Pop a message from the buffer

fn peek(&self) -> Result<Option<&T>, NerveError>

Peek at the next message without removing it

fn len(&self) -> usize

Get the number of messages in the buffer

fn is_empty(&self) -> bool

Check if buffer is empty

fn is_full(&self) -> bool

Check if buffer is full

fn capacity(&self) -> usize

Get buffer capacity

fn utilization(&self) -> f64

Get buffer utilization percentage

fn clear(&mut self) -> Result<usize, NerveError>

Clear all messages from the buffer

Implementors§