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§
Trait Implementations§
Source§impl Backend for InMemoryBackend
impl Backend for InMemoryBackend
Source§fn get_committed_versions(
&self,
key: &[u8],
) -> Result<Vec<CommittedVersion>, String>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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§impl Clone for InMemoryBackend
impl Clone for InMemoryBackend
Source§fn clone(&self) -> InMemoryBackend
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InMemoryBackend
impl Debug for InMemoryBackend
Source§impl Default for InMemoryBackend
impl Default for InMemoryBackend
Source§fn default() -> InMemoryBackend
fn default() -> InMemoryBackend
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for InMemoryBackend
impl RefUnwindSafe for InMemoryBackend
impl Send for InMemoryBackend
impl Sync for InMemoryBackend
impl Unpin for InMemoryBackend
impl UnsafeUnpin for InMemoryBackend
impl UnwindSafe for InMemoryBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more