pub struct BoundedHistory<T> { /* private fields */ }Expand description
Count- and payload-bounded heap history of consumer-owned structured rows.
Oldest rows are evicted first. Iteration borrows immutable rows in append
order and can be reversed for newest-first views. No Clone bound is needed.
There is no clock, timestamp ordering, sequence identity, truncation, codec,
checkpoint or global recorder. Consumers retain sanitization, field bounds,
privacy, synchronization and lifecycle; this is not a durable byte format.
Interior-mutability payloads must not grow their charged content while retained.
Implementations§
Source§impl<T> BoundedHistory<T>
impl<T> BoundedHistory<T>
Sourcepub const fn new(limits: HistoryLimits) -> Self
pub const fn new(limits: HistoryLimits) -> Self
Construct an empty history without allocating.
Sourcepub fn append(
&mut self,
value: T,
payload_bytes: usize,
) -> Result<HistoryAppend, HistoryRejection<T>>
pub fn append( &mut self, value: T, payload_bytes: usize, ) -> Result<HistoryAppend, HistoryRejection<T>>
Append one pre-admitted payload, evicting oldest rows until both bounds fit.
Work is bounded by the configured retained row count. Payload charges are stored at admission and are not recomputed during eviction.
§Errors
Returns the original input when disabled or individually oversized. Refusal changes neither retained rows nor payload accounting.
Sourcepub fn entries(
&self,
) -> impl DoubleEndedIterator<Item = &T> + ExactSizeIterator + '_
pub fn entries( &self, ) -> impl DoubleEndedIterator<Item = &T> + ExactSizeIterator + '_
Borrow rows oldest first; reverse the iterator for newest-first projection.
Sourcepub const fn retained_payload_bytes(&self) -> usize
pub const fn retained_payload_bytes(&self) -> usize
Current sum of caller-accounted retained payload bytes.
Sourcepub const fn limits(&self) -> HistoryLimits
pub const fn limits(&self) -> HistoryLimits
Immutable consumer-selected bounds.