pub struct MemoryStore { /* private fields */ }Expand description
Handle to a memory directory on disk.
Implementations§
Source§impl MemoryStore
impl MemoryStore
Sourcepub fn open(dir: impl Into<PathBuf>) -> Result<Self>
pub fn open(dir: impl Into<PathBuf>) -> Result<Self>
Open a store rooted at dir. Creates the directory and a default
MEMORY.md index if either is missing.
Sourcepub fn open_default() -> Result<Self>
pub fn open_default() -> Result<Self>
Open the default store. Uses $MERLION_HOME/memory if set, else
~/.merlion/memory via dirs::home_dir.
Sourcepub fn read(&self, name: &str) -> Result<Memory>
pub fn read(&self, name: &str) -> Result<Memory>
Read a single memory by slug. Fails if the file is missing or malformed.
Sourcepub fn write(&self, m: &Memory) -> Result<()>
pub fn write(&self, m: &Memory) -> Result<()>
Write a memory to disk, creating or overwriting <name>.md and
updating the index line in MEMORY.md.
created_atis preserved if the file already exists.updated_atis always set toUtc::now().
Sourcepub fn delete(&self, name: &str) -> Result<()>
pub fn delete(&self, name: &str) -> Result<()>
Delete a memory. Idempotent: missing files are not an error. The matching index line, if present, is stripped.
Sourcepub fn render_context_block(&self, max_chars: usize) -> Result<String>
pub fn render_context_block(&self, max_chars: usize) -> Result<String>
Build a context block suitable for system-prompt injection. Returns
an empty string when there are no memories. Stops adding lines once
the cumulative size would exceed max_chars.
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