pub struct MemoryStore { /* private fields */ }Expand description
Persistent memory store backed by a single markdown file.
Entries are plain text separated by § on its own line. The store enforces
a character limit, duplicate detection, and basic security scanning.
Implementations§
Source§impl MemoryStore
impl MemoryStore
Sourcepub fn load(path: &Path, char_limit: usize) -> Result<Self>
pub fn load(path: &Path, char_limit: usize) -> Result<Self>
Load a memory store from disk. Creates the file if it doesn’t exist.
Sourcepub fn add(&mut self, content: &str) -> Result<MemoryResult>
pub fn add(&mut self, content: &str) -> Result<MemoryResult>
Append a new entry. Returns error if at capacity or content is rejected.
Sourcepub fn replace(&mut self, old_text: &str, content: &str) -> Result<MemoryResult>
pub fn replace(&mut self, old_text: &str, content: &str) -> Result<MemoryResult>
Replace the entry uniquely matching old_text with new content.
Sourcepub fn remove(&mut self, old_text: &str) -> Result<MemoryResult>
pub fn remove(&mut self, old_text: &str) -> Result<MemoryResult>
Remove the entry uniquely matching old_text.
pub fn entries(&self) -> &[String]
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more