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
impl MemoryStorage
pub fn new() -> MemoryStorage
Sourcepub fn clone_data(&self) -> BTreeMap<Box<str>, StorageValue>
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
impl Default for MemoryStorage
Source§fn default() -> MemoryStorage
fn default() -> MemoryStorage
Returns the “default value” for a type. Read more
Source§impl Storage for MemoryStorage
impl Storage for MemoryStorage
Source§fn set(&self, key: &str, value: StorageValue)
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>
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 scan<'s>(
&'s self,
prefix: &str,
) -> Box<dyn Iterator<Item = (Box<str>, StorageValue)> + 's>
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 moreSource§fn clear(&self)
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 moreAuto Trait Implementations§
impl !Freeze for MemoryStorage
impl !RefUnwindSafe for MemoryStorage
impl Send for MemoryStorage
impl !Sync for MemoryStorage
impl Unpin for MemoryStorage
impl UnsafeUnpin for MemoryStorage
impl UnwindSafe for MemoryStorage
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