Skip to main content

Snapshot

Struct Snapshot 

Source
pub struct Snapshot<T> { /* private fields */ }
Expand description

A stable, zero-copy view of the data currently retained by an AtomicLog.

A snapshot owns Arcs to every segment it exposes, so the underlying storage remains alive for the lifetime of the snapshot. Refreshing a snapshot replaces its contents with a newer captured view.

Implementations§

Source§

impl<T> Snapshot<T>

Source

pub fn refresh(&mut self)

Refreshes the snapshot in place to reflect the current state of the log.

This attempts a cheap same-head extension first, then an incremental segment append, and falls back to a full rebuild if continuity has been lost.

Source

pub fn len(&self) -> usize

Returns the total number of elements visible through this snapshot.

Source

pub fn is_empty(&self) -> bool

Returns true if the snapshot contains no elements.

Source

pub fn iter(&self) -> Iter<'_, T>

Iterates over all visible values as a flat &T stream.

Source

pub fn chunks(&self) -> Chunks<'_, T>

Iterates over the snapshot one backing segment at a time.

Source

pub fn log(&self) -> AtomicLog<T>

Returns a read handle for the log this snapshot came from.

Trait Implementations§

Source§

impl<T> Debug for Snapshot<T>

Source§

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

Formats the value using the given formatter. 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<'a, T> IntoIterator for &'a Snapshot<T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Snapshot<T>

§

impl<T> !RefUnwindSafe for Snapshot<T>

§

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

§

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

§

impl<T> Unpin for Snapshot<T>

§

impl<T> UnsafeUnpin for Snapshot<T>

§

impl<T> !UnwindSafe for Snapshot<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> 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, 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.