pub struct SequenceCounter { /* private fields */ }Expand description
Hands out increasing sequence numbers, starting at 1.
Implementations§
Source§impl SequenceCounter
impl SequenceCounter
Sourcepub fn persistent(
path: impl Into<PathBuf>,
reserve: u64,
) -> PhyTraceResult<Self>
pub fn persistent( path: impl Into<PathBuf>, reserve: u64, ) -> PhyTraceResult<Self>
A counter backed by the state file at path, which is created on
first use.
Fails if the file exists but cannot be read or parsed: starting again from 1 would make new events look like replays.
Sourcepub fn is_persistent(&self) -> bool
pub fn is_persistent(&self) -> bool
Whether the counter is backed by a state file.
Sourcepub fn current(&self) -> PhyTraceResult<u64>
pub fn current(&self) -> PhyTraceResult<u64>
The last number issued (0 before the first).
Sourcepub fn next(&self) -> PhyTraceResult<u64>
pub fn next(&self) -> PhyTraceResult<u64>
Issue the next sequence number.
Sourcepub fn close(&self) -> PhyTraceResult<()>
pub fn close(&self) -> PhyTraceResult<()>
Record the exact next number, so a clean restart has no gap.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SequenceCounter
impl RefUnwindSafe for SequenceCounter
impl Send for SequenceCounter
impl Sync for SequenceCounter
impl Unpin for SequenceCounter
impl UnsafeUnpin for SequenceCounter
impl UnwindSafe for SequenceCounter
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