Rindle docs and package mapSkip to main content

MemoryStorage

Struct MemoryStorage 

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

In-RAM Storage. A BTreeMap<Box<str>, StorageValue> (kept private — see the module docs) gives the sorted-key invariant, O(log n) point ops, and a native range for the prefix scan. RefCell provides the interior mutability the &self trait methods need (single-threaded per pipeline — foundations §1.3, so no Sync required).

Implementations§

Source§

impl MemoryStorage

Source

pub fn new() -> MemoryStorage

Source

pub fn clone_data(&self) -> BTreeMap<Box<str>, StorageValue>

Test/debug snapshot (ports cloneData, memory-storage.ts:47). Returns an owned copy of the whole map; the BTreeMap type is intentionally not part of the Storage trait surface, so this leaks only from the concrete type, keeping the backing swappable (module docs).

Trait Implementations§

Source§

impl Default for MemoryStorage

Source§

fn default() -> MemoryStorage

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

impl Storage for MemoryStorage

Source§

fn set(&self, key: &str, value: StorageValue)

Insert or overwrite key’s value (spec 10 §3.1, E3).
Source§

fn get(&self, key: &str) -> Option<StorageValue>

Owned lookup. None if absent (E1). The JS get(key, def) default is a caller concern — use get(k).unwrap_or(default) (spec 10 §6 deviation D1); we do not bake it into the signature. The returned value is owned (never a borrow into the store), so the operator may hold/mutate it past a later set regardless of backend (spec 10 §3.2 inv.3, E11).
Source§

fn del(&self, key: &str)

Remove key. No-op if absent (E4).
Source§

fn scan<'s>( &'s self, prefix: &str, ) -> Box<dyn Iterator<Item = (Box<str>, StorageValue)> + 's>

Ascending prefix scan. Yields owned (key, value) pairs in byte-ascending key order, starting at the first key >= prefix and stopping at the first key not starting with prefix (spec 10 §3.2). prefix == "" scans the whole keyspace in order (E5/E7). Read more
Source§

fn clear(&self)

Drop every key in this store, leaving it an empty namespace. Called by Graph::destroy_pipeline to reclaim a torn-down operator’s scratch state while keeping the slot reusable (the slot — and, for a SQLite-backed store, its op_id namespace — is recycled by the next alloc_storage, so we must clear contents, not drop the store object). 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> 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.