pub struct Lsn(/* private fields */);Expand description
Monotonic log sequence number.
LSN 0 is reserved for “empty / never written” so a snapshot’s
wal_lsn = 0 cannot be mistaken for “I checkpointed at the very first
record”. Allocators advance from 1.
Internally an LSN is opaque: callers only rely on the total order. The
representation is left as a single u64 for now; a future change to a
(segment_id, offset) packing is non-breaking because every consumer
goes through these accessors.
Implementations§
Source§impl Lsn
impl Lsn
pub const ZERO: Lsn
pub const fn new(value: u64) -> Self
pub const fn raw(self) -> u64
pub const fn is_zero(self) -> bool
Sourcepub fn checked_next(self) -> Option<Self>
pub fn checked_next(self) -> Option<Self>
Returns the next LSN, or None if the counter is exhausted.
Sourcepub fn next(self) -> Self
pub fn next(self) -> Self
Returns the next LSN, saturating at u64::MAX.
Production WAL allocation uses Self::checked_next so exhaustion
can surface as a structured error. This convenience method is kept
non-panicking for low-level callers and tests that only need simple
monotonic advancement.