pub struct FileMemoryStore { /* private fields */ }Expand description
A deterministic, path-sandboxed collection of memory files under one root directory.
Implementations§
Source§impl FileMemoryStore
impl FileMemoryStore
Sourcepub fn new(root: impl Into<PathBuf>) -> Result<Self, FileMemoryError>
pub fn new(root: impl Into<PathBuf>) -> Result<Self, FileMemoryError>
Opens (creating if needed) a memory root and canonicalizes it so every later path check is against a single absolute base.
Sourcepub fn create(&self, name: &str, content: &str) -> Result<(), FileMemoryError>
pub fn create(&self, name: &str, content: &str) -> Result<(), FileMemoryError>
Creates a new memory. Fails if a memory with the same name already exists.
Sourcepub fn view(&self, name: &str) -> Result<String, FileMemoryError>
pub fn view(&self, name: &str) -> Result<String, FileMemoryError>
Returns the full content of a memory.
Sourcepub fn write(&self, name: &str, content: &str) -> Result<(), FileMemoryError>
pub fn write(&self, name: &str, content: &str) -> Result<(), FileMemoryError>
Overwrites a memory’s content whether or not it exists.
Unlike Self::create this never fails on an existing name; it is the
upsert primitive used by higher-level stacks (e.g. re-remembering).
Sourcepub fn append(&self, name: &str, content: &str) -> Result<(), FileMemoryError>
pub fn append(&self, name: &str, content: &str) -> Result<(), FileMemoryError>
Appends content to an existing memory.
Sourcepub fn str_replace(
&self,
name: &str,
old: &str,
new: &str,
) -> Result<(), FileMemoryError>
pub fn str_replace( &self, name: &str, old: &str, new: &str, ) -> Result<(), FileMemoryError>
Replaces the first exact occurrence of old with new in a memory.
Fails with FileMemoryError::OldTextNotFound if old is not present, rather
than silently corrupting the file — str_replace must be idempotent and observable.
Sourcepub fn rename(&self, name: &str, new_name: &str) -> Result<(), FileMemoryError>
pub fn rename(&self, name: &str, new_name: &str) -> Result<(), FileMemoryError>
Renames a memory to a new validated name.
Sourcepub fn list(&self) -> Result<Vec<MemoryEntry>, FileMemoryError>
pub fn list(&self) -> Result<Vec<MemoryEntry>, FileMemoryError>
Lists all memories, newest-modified first.