Skip to main content

MemoryStorage

Struct MemoryStorage 

Source
pub struct MemoryStorage { /* private fields */ }
Expand description

Detached in-memory reference implementation of Storage. Reads return owned copies.

Implementations§

Source§

impl MemoryStorage

Source

pub fn new() -> Self

Source

pub fn with_commit_sink(self, sink: CommitSink) -> Self

Every later commit goes through sink before it is applied.

Source

pub fn prepare_commit( &self, writes: Vec<StorageWrite>, seq: Option<Seq>, ) -> Result<PreparedCommit>

Validate one commit and resolve its document copies without changing observable state. seq defaults to the next sequence; a replaying caller (JSONL recovery) supplies the recorded one, which must not go backwards.

Source

pub fn apply_commit(&mut self, prepared: PreparedCommit) -> Seq

Apply a commit prepared against the current state; nothing in it can fail.

Trait Implementations§

Source§

impl Default for MemoryStorage

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Storage for MemoryStorage

Source§

fn commit(&mut self, writes: Vec<StorageWrite>) -> Result<Seq>

Atomically persist one batch and return its sequence; later reads observe it.
Source§

fn mint_id(&mut self) -> Result<u64>

A fresh ID from the Session-global namespace, greater than every ID minted or stored before, across reopen.
Source§

fn conversation(&self, id: ConversationId) -> Result<Option<ConversationRecord>>

Source§

fn scan_conversations( &self, query: &ConversationQuery, limit: usize, cursor: Option<&Cursor>, ) -> Result<Page<ConversationRecord>>

Source§

fn entry(&self, id: EntryId) -> Result<Option<StoredEntry>>

Source§

fn visible_entry( &self, conversation_id: ConversationId, id: EntryId, ) -> Result<Option<StoredEntry>>

One entry only when it is visible through the conversation’s fork ancestry.
Source§

fn find_latest_head_marker( &self, conversation_id: ConversationId, at_or_before: Option<EntryId>, ) -> Result<Option<EntryRecord>>

The newest visible entry with a head at or below the optional inclusive cutoff.
Source§

fn scan_entries( &self, query: &EntryQuery, limit: usize, cursor: Option<&Cursor>, ) -> Result<Page<EntryRecord>>

Source§

fn task(&self, id: TaskId) -> Result<Option<TaskRecord>>

Source§

fn scan_tasks( &self, query: &TaskQuery, limit: usize, cursor: Option<&Cursor>, ) -> Result<Page<TaskRecord>>

Source§

fn submission(&self, id: SubmissionId) -> Result<Option<SubmissionRecord>>

Source§

fn scan_submissions( &self, query: &SubmissionQuery, limit: usize, cursor: Option<&Cursor>, ) -> Result<Page<SubmissionRecord>>

Source§

fn submission_by_request( &self, conversation_id: ConversationId, request_id: &str, ) -> Result<Option<SubmissionRecord>>

Source§

fn find_document( &self, address: &DocumentAddress, at: DocumentPoint, ) -> Result<Option<DocumentRecord>>

The incarnation occupying one exact logical address at the point.
Source§

fn document( &self, id: DocumentId, at: DocumentPoint, ) -> Result<Option<StoredDocument>>

Materialize one incarnation by ID at the point, without following a replacement at its address.
Source§

fn scan_documents( &self, query: &DocumentQuery, limit: usize, cursor: Option<&Cursor>, ) -> Result<Page<DocumentRecord>>

Source§

fn close(&mut self) -> Result<()>

Release resources; every later operation fails.

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.