pub struct LogCheckpoint<'a> { /* private fields */ }Expand description
Borrowed complete checkpoint view; obtaining/iterating it allocates nothing. Hosts own encoding budgets. The immutable borrow keeps rows and watermarks fixed.
Implementations§
Source§impl<'a> LogCheckpoint<'a>
impl<'a> LogCheckpoint<'a>
Sourcepub fn entries(
&self,
) -> impl ExactSizeIterator<Item = &'a Entry> + DoubleEndedIterator + 'a
pub fn entries( &self, ) -> impl ExactSizeIterator<Item = &'a Entry> + DoubleEndedIterator + 'a
All retained rows, oldest first, without cloning text.
Sourcepub const fn next_sequence(&self) -> Option<u64>
pub const fn next_sequence(&self) -> Option<u64>
Next identity, including permanent exhaustion after complete pruning.
Examples found in repository?
examples/worker.rs (line 44)
6fn main() {
7 let mut log = Log::new(Limits {
8 max_entries: NonZeroUsize::new(8).expect("positive capacity"),
9 max_message_bytes: 32,
10 max_label_bytes: 16,
11 max_text_bytes: 512,
12 });
13 for (created_at_secs, level, message) in [
14 (10, Level::Info, "delivery accepted"),
15 (
16 11,
17 Level::Warn,
18 "provider reply is still unknown; reconcile before retry",
19 ),
20 (12, Level::Ok, "original delivery reconciled"),
21 ] {
22 log.append(EntryInput {
23 created_at_secs,
24 level,
25 source: "worker",
26 topic: Some("delivery"),
27 message,
28 })
29 .expect("valid bounded entry");
30 }
31 let scan = log.visit_page(
32 Filter::default(),
33 PageRequest {
34 before: None,
35 max_results: NonZeroUsize::new(8).expect("positive results"),
36 max_scanned: NonZeroUsize::new(8).expect("positive scan"),
37 },
38 |entry| {
39 println!("{} {:?}: {}", entry.sequence, entry.level, entry.message);
40 ControlFlow::Continue(())
41 },
42 );
43 assert_eq!(scan.matched, 3);
44 assert_eq!(log.checkpoint().next_sequence(), Some(3));
45 let batch = log.prune_expired(16, 5, 1);
46 assert_eq!(batch.removed, 1);
47 assert_eq!(log.next_expiry_secs(5), Some(17));
48}Sourcepub const fn last_created_at_secs(&self) -> Option<u64>
pub const fn last_created_at_secs(&self) -> Option<u64>
Last admitted time, including after complete pruning.
Trait Implementations§
Source§impl<'a> Clone for LogCheckpoint<'a>
impl<'a> Clone for LogCheckpoint<'a>
impl<'a> Copy for LogCheckpoint<'a>
Auto Trait Implementations§
impl<'a> Freeze for LogCheckpoint<'a>
impl<'a> RefUnwindSafe for LogCheckpoint<'a>
impl<'a> Send for LogCheckpoint<'a>
impl<'a> Sync for LogCheckpoint<'a>
impl<'a> Unpin for LogCheckpoint<'a>
impl<'a> UnsafeUnpin for LogCheckpoint<'a>
impl<'a> UnwindSafe for LogCheckpoint<'a>
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