pub struct RingBufferChannel<T> { /* private fields */ }Expand description
Ring buffer channel for append-heavy fields with bounded size
Wraps a Vec<T> with a maximum capacity. When new values are appended
and the capacity is exceeded, the oldest elements are removed. This
prevents unbounded memory growth for append-heavy fields like messages,
events, and logs.
§Examples
ⓘ
use juncture_core::state::channel::RingBufferChannel;
let mut ch = RingBufferChannel::new(Vec::new(), 100);
ch.update(vec!["msg1".to_string(), "msg2".to_string()]);
assert_eq!(ch.get().len(), 2);Implementations§
Trait Implementations§
Source§impl<T: Send + Sync + Serialize + DeserializeOwned + 'static> Channel<Vec<T>> for RingBufferChannel<T>
impl<T: Send + Sync + Serialize + DeserializeOwned + 'static> Channel<Vec<T>> for RingBufferChannel<T>
Source§fn update(&mut self, values: Vec<Vec<T>>) -> bool
fn update(&mut self, values: Vec<Vec<T>>) -> bool
Update the channel with new values. Returns true if the value changed.
Source§fn consume(&mut self) -> bool
fn consume(&mut self) -> bool
Check if the channel has been consumed (for trigger-based activation)
Source§fn checkpoint(&self) -> Option<Value>
fn checkpoint(&self) -> Option<Value>
Create a checkpoint of the current value for persistence
Source§impl<T: Clone> Clone for RingBufferChannel<T>
impl<T: Clone> Clone for RingBufferChannel<T>
Source§fn clone(&self) -> RingBufferChannel<T>
fn clone(&self) -> RingBufferChannel<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<T> Freeze for RingBufferChannel<T>
impl<T> RefUnwindSafe for RingBufferChannel<T>where
T: RefUnwindSafe,
impl<T> Send for RingBufferChannel<T>where
T: Send,
impl<T> Sync for RingBufferChannel<T>where
T: Sync,
impl<T> Unpin for RingBufferChannel<T>where
T: Unpin,
impl<T> UnsafeUnpin for RingBufferChannel<T>
impl<T> UnwindSafe for RingBufferChannel<T>where
T: UnwindSafe,
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