Skip to main content

AtomicLog

Struct AtomicLog 

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

Source

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.

Source

pub fn new_claimed( retained_capacity: usize, segment_capacity: usize, ) -> (Writer<T>, Self)

Creates a new log and immediately claims its writer.

Source

pub fn retained_capacity(&self) -> usize

Returns the configured logical retained capacity, in elements.

Source

pub fn segment_capacity(&self) -> usize

Returns the fixed segment size, in elements.

Source

pub fn is_writer_claimed(&self) -> bool

Returns true if this log currently has a claimed writer.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<T> Clone for AtomicLog<T>

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<T> From<AtomicLog<T>> for Snapshot<T>

Source§

fn from(log: AtomicLog<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Snapshot<T>> for AtomicLog<T>

Source§

fn from(snapshot: Snapshot<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Writer<T>> for AtomicLog<T>

Source§

fn from(writer: Writer<T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> Freeze for AtomicLog<T>

§

impl<T> !RefUnwindSafe for AtomicLog<T>

§

impl<T> Send for AtomicLog<T>
where T: Send + Sync,

§

impl<T> Sync for AtomicLog<T>
where T: Send + Sync,

§

impl<T> Unpin for AtomicLog<T>

§

impl<T> UnsafeUnpin for AtomicLog<T>

§

impl<T> !UnwindSafe for AtomicLog<T>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.