Skip to main content

InMemoryBackend

Struct InMemoryBackend 

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

A simple, non-durable in-memory implementation of the Backend trait. Intended for testing, examples, and rapid prototyping.

Implementations§

Source§

impl InMemoryBackend

Source

pub fn new() -> Self

Creates a new, empty in-memory backend.

Trait Implementations§

Source§

impl Backend for InMemoryBackend

Source§

fn get_committed_versions( &self, key: &[u8], ) -> Result<Vec<CommittedVersion>, String>

Returns all committed versions for a key, ordered ascending by commit_ts.
Source§

fn get_latest_committed( &self, key: &[u8], ) -> Result<Option<CommittedVersion>, String>

Returns the most recent committed version for a key, if any.
Source§

fn get_visible_committed( &self, key: &[u8], read_ts: Timestamp, ) -> Result<Option<CommittedVersion>, String>

Returns the most recent committed version for a key that is visible at or before read_ts.
Source§

fn get_latest_commit_ts(&self, key: &[u8]) -> Result<Option<Timestamp>, String>

Returns the timestamp of the most recent committed version for a key, if any.
Source§

fn get_intent(&self, key: &[u8]) -> Result<Option<Intent>, String>

Fetches the active intent for a given key, if any exists.
Source§

fn put_intent(&mut self, intent: Intent) -> Result<(), String>

Writes a single intent to the backend.
Source§

fn remove_intent( &mut self, key: &[u8], txn_id: TxnId, start_ts: Timestamp, ) -> Result<bool, String>

Removes an intent from the backend if it matches the given txn_id and start_ts. Returns true if removed, false otherwise.
Source§

fn put_committed(&mut self, version: CommittedVersion) -> Result<(), String>

Writes a single committed version to the backend.
Source§

fn put_committed_batch( &mut self, versions: Vec<CommittedVersion>, ) -> Result<(), String>

Writes multiple committed versions atomically. Must be all-or-nothing.
Source§

fn remove_committed_version( &mut self, key: &[u8], commit_ts: Timestamp, ) -> Result<(), String>

Removes a specific committed version during garbage collection.
Source§

fn all_keys(&self) -> Result<Vec<Key>, String>

Returns a deduplicated, sorted list of all keys currently managed by the backend.
Source§

fn put_intents_batch(&mut self, intents: Vec<Intent>) -> Result<(), String>

Writes multiple intents atomically. Must be all-or-nothing.
Source§

fn commit_intents_batch( &mut self, commits: Vec<CommittedVersion>, removed_intents: Vec<(Key, TxnId, Timestamp)>, ) -> Result<(), String>

Converts multiple intents into committed versions atomically. Must create the versions and remove the intents in a single durable transaction.
Source§

fn remove_intents_batch( &mut self, intents: Vec<(Key, TxnId, Timestamp)>, ) -> Result<(), String>

Removes multiple intents atomically. Must be all-or-nothing.
Source§

fn keys_from( &self, start: Option<&[u8]>, limit: usize, ) -> Result<Vec<Key>, String>

Returns up to limit keys strictly ordered, starting from start (inclusive if provided).
Source§

fn keys_from_prefix( &self, prefix: &[u8], start: Option<&[u8]>, limit: usize, ) -> Result<Vec<Key>, String>

Returns up to limit keys starting with prefix, strictly ordered, starting from start if provided. Excludes intents and returns committed keys only.
Source§

fn get_committed_timestamps_before( &self, key: &[u8], before_ts: Timestamp, limit: usize, ) -> Result<Vec<Timestamp>, String>

Returns the limit newest commit timestamps strictly before before_ts for the given key. Ordered descending (newest first).
Source§

fn collapse_tombstone( &mut self, key: &[u8], tombstone_ts: Timestamp, older_ts: Vec<Timestamp>, ) -> Result<(), String>

Atomically removes a tombstone version and every supplied older version. Callers must pass the complete older version set for a final tombstone collapse.
Source§

impl Clone for InMemoryBackend

Source§

fn clone(&self) -> InMemoryBackend

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 Debug for InMemoryBackend

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for InMemoryBackend

Source§

fn default() -> InMemoryBackend

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

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