pub struct MemoryStore { /* private fields */ }Expand description
An in-memory tree store that implements the StructFS store conventions:
- Reading a prefix returns its subtree as a
Value::Mapof children. - Writing deep paths creates intermediate maps as needed.
- Writing
Value::Nulldeletes the node and its entire subtree (component-wise: deletingaccountsdoes not touchaccounts_other). - Writing a
Value::Mapat a parent replaces the full state under that path — stale descendants do not survive.
This is the reference implementation certified by the
conformance suite; use that suite to verify
other stores implement the same semantics.
§Example
use structfs_core_store::{MemoryStore, Reader, Writer, Record, Value, path};
let mut store = MemoryStore::new();
store.write(&path!("users/alice/name"), Record::parsed(Value::from("Alice"))).unwrap();
// Reading the prefix returns the subtree
let users = store.read(&path!("users")).unwrap().unwrap();
assert!(users.as_value().unwrap().is_map());
// Null deletes the subtree
store.write(&path!("users"), Record::parsed(Value::Null)).unwrap();
assert!(store.read(&path!("users/alice/name")).unwrap().is_none());Implementations§
Trait Implementations§
Source§impl Debug for MemoryStore
impl Debug for MemoryStore
Source§impl Default for MemoryStore
impl Default for MemoryStore
Source§fn default() -> MemoryStore
fn default() -> MemoryStore
Returns the “default value” for a type. Read more
Source§impl Reader for MemoryStore
impl Reader for MemoryStore
Auto Trait Implementations§
impl Freeze for MemoryStore
impl RefUnwindSafe for MemoryStore
impl Send for MemoryStore
impl Sync for MemoryStore
impl Unpin for MemoryStore
impl UnsafeUnpin for MemoryStore
impl UnwindSafe for MemoryStore
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