Skip to main content

LogCheckpoint

Struct LogCheckpoint 

Source
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>

Source

pub const fn limits(&self) -> Limits

Fixed retention limits.

Source

pub fn entries( &self, ) -> impl ExactSizeIterator<Item = &'a Entry> + DoubleEndedIterator + 'a

All retained rows, oldest first, without cloning text.

Source

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}
Source

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>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for LogCheckpoint<'a>

Source§

impl<'a> Debug for LogCheckpoint<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Forget for LogCheckpoint<'a>

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.