pub struct Log { /* private fields */ }Expand description
Caller-owned heap history with fixed limits and monotonic append watermarks.
Implementations§
Source§impl Log
impl Log
Sourcepub const fn new(limits: Limits) -> Self
pub const fn new(limits: Limits) -> Self
Construct an empty log without preallocating the configured maximum.
Sourcepub const fn limits(&self) -> Limits
pub const fn limits(&self) -> Limits
Return the fixed bounds without copying retained messages.
Sourcepub const fn retained_text_bytes(&self) -> usize
pub const fn retained_text_bytes(&self) -> usize
Combined retained text bytes; excludes metadata, spare capacity and allocator overhead.
Sourcepub const fn checkpoint(&self) -> LogCheckpoint<'_>
pub const fn checkpoint(&self) -> LogCheckpoint<'_>
Borrow rows and append watermarks together, without copying or consuming the log.
Sourcepub fn snapshot(&self) -> LogSnapshot
pub fn snapshot(&self) -> LogSnapshot
Copy all retained rows and both append watermarks for explicit checkpointing. Work and allocation scale with retained history, not a cursor-page limit.
Sourcepub fn into_snapshot(self) -> LogSnapshot
pub fn into_snapshot(self) -> LogSnapshot
Consume the log into a checkpoint without cloning retained entries. Fixed limits, row order and both append watermarks are preserved, including empty histories and permanent sequence exhaustion.
Sourcepub fn restore(snapshot: LogSnapshot) -> Result<Self, RestoreError>
pub fn restore(snapshot: LogSnapshot) -> Result<Self, RestoreError>
Admit a complete checkpoint without replaying entries or reissuing identities.
Empty retained history preserves its original append watermarks. Admission proves internal consistency, not source authenticity or host continuity. Byte decoders must bound allocation before constructing the checkpoint.
§Errors
Rejects bounds, row ordering, watermarks and truncation states that cannot result from this engine’s append/retention operations.
Sourcepub fn append(
&mut self,
input: EntryInput<'_>,
) -> Result<AppendReceipt, AppendError>
pub fn append( &mut self, input: EntryInput<'_>, ) -> Result<AppendReceipt, AppendError>
Admit one row, evicting the oldest rows until both count and text ceilings fit.
§Errors
Returns a typed refusal for oversized labels, regressed time or exhausted sequence identities, or a row that cannot fit the text budget by itself. Validation completes before any eviction or mutation. Error priority is source, topic, regressed time, sequence exhaustion, then total text budget.
Sourcepub fn prune_expired(
&mut self,
now_secs: u64,
max_age_secs: u64,
max_remove: usize,
) -> RetentionBatch
pub fn prune_expired( &mut self, now_secs: u64, max_age_secs: u64, max_remove: usize, ) -> RetentionBatch
Remove at most max_remove entries strictly older than the age cutoff.
An entry remains available through its full configured age second.
Sourcepub fn next_expiry_secs(&self, max_age_secs: u64) -> Option<u64>
pub fn next_expiry_secs(&self, max_age_secs: u64) -> Option<u64>
First second at which the oldest row expires; None for empty history or overflow.
Sourcepub fn page(&self, filter: Filter<'_>, request: PageRequest) -> Page<'_>
pub fn page(&self, filter: Filter<'_>, request: PageRequest) -> Page<'_>
Scan newest-first without cloning retained messages or counting every match.
Follow next_before with the same filters, including after an empty page.
Sourcepub fn visit_page<'a>(
&'a self,
filter: Filter<'_>,
request: PageRequest,
visit: impl FnMut(&'a Entry) -> ControlFlow<()>,
) -> PageScan
pub fn visit_page<'a>( &'a self, filter: Filter<'_>, request: PageRequest, visit: impl FnMut(&'a Entry) -> ControlFlow<()>, ) -> PageScan
Visit matching rows without allocating a page collection or cloning text.
Break stops after consuming that matched row; the returned cursor resumes
at the next older candidate. Empty filtered scans can still have a cursor.
Callback work/allocation belongs to the caller; filter/limits match page.