pub struct AtomicLog<T> { /* private fields */ }Expand description
Shared read handle for a segmented rolling log.
AtomicLog<T> is cheaply clonable and can be sent to many reader threads. Readers use
snapshot to capture a stable, zero-copy view of the currently
retained data.
Implementations§
Source§impl<T> AtomicLog<T>
impl<T> AtomicLog<T>
Sourcepub fn new(retained_capacity: usize, segment_capacity: usize) -> Self
pub fn new(retained_capacity: usize, segment_capacity: usize) -> Self
Creates a new log without claiming a writer.
retained_capacity is the target logical retention size in elements. The current
implementation retains whole segments, so the observed window may exceed this value.
segment_capacity is the number of elements stored in each segment and remains fixed
for the lifetime of the log.
§Panics
Panics if either capacity is zero.
Sourcepub fn new_claimed(
retained_capacity: usize,
segment_capacity: usize,
) -> (Writer<T>, Self)
pub fn new_claimed( retained_capacity: usize, segment_capacity: usize, ) -> (Writer<T>, Self)
Creates a new log and immediately claims its writer.
Sourcepub fn retained_capacity(&self) -> usize
pub fn retained_capacity(&self) -> usize
Returns the configured logical retained capacity, in elements.
Sourcepub fn segment_capacity(&self) -> usize
pub fn segment_capacity(&self) -> usize
Returns the fixed segment size, in elements.
Sourcepub fn is_writer_claimed(&self) -> bool
pub fn is_writer_claimed(&self) -> bool
Returns true if this log currently has a claimed writer.
Sourcepub fn snapshot(&self) -> Snapshot<T>
pub fn snapshot(&self) -> Snapshot<T>
Captures a stable snapshot of the currently retained data.
The snapshot borrows no locks and keeps its backing segments alive through Arc
ownership, so readers can iterate over the result without copying values out of the
log.
Sourcepub fn try_claim_writer(&self) -> Option<Writer<T>>
pub fn try_claim_writer(&self) -> Option<Writer<T>>
Attempts to claim exclusive write access to this log.
Returns None if another Writer currently exists. Dropping the returned writer
releases the claim without discarding the log’s retained segment state.