Skip to main content

Store

Trait Store 

Source
pub trait Store<Meta, Entry> {
    // Required methods
    fn get(&self) -> Option<&Meta>;
    fn set(&mut self, meta: Meta);
    fn append(&mut self, entry: Entry) -> Position;
    fn read_from(&self, from: Position) -> Vec<&Entry>;
    fn end(&self) -> Position;
}
Expand description

One value that is replaced, and a sequence that grows.

The split is the point: metadata is small and rewritten, entries accumulate. Rewriting something that accumulates costs O(n²) over a run, so it must be appended instead.

A protocol that keeps nothing durably declares both types uninhabited, and then set and append take an argument that cannot be constructed. Reads stay callable and return nothing.

Required Methods§

Source

fn get(&self) -> Option<&Meta>

Source

fn set(&mut self, meta: Meta)

Source

fn append(&mut self, entry: Entry) -> Position

Source

fn read_from(&self, from: Position) -> Vec<&Entry>

Source

fn end(&self) -> Position

One past the last entry.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Store<Infallible, Infallible> for NoStore

Source§

impl<Meta, Entry> Store<Meta, Entry> for MemStore<Meta, Entry>