pub struct Memory {
pub id: String,
pub memory_type: MemoryType,
pub content: String,
pub tags: Vec<String>,
pub created: String,
}Expand description
A single memory entry.
Memories are stored in .ralph/agent/memories.md with the following format:
### mem-1737372000-a1b2
> The actual memory content
> Can span multiple lines
<!-- tags: tag1, tag2 | created: 2025-01-20 -->Fields§
§id: StringUnique identifier (format: mem-{unix_timestamp}-{4_hex_chars})
memory_type: MemoryTypeClassification of this memory
content: StringThe actual memory content (may contain newlines)
Tags for categorization and search
created: StringCreation date (format: YYYY-MM-DD)
Implementations§
Source§impl Memory
impl Memory
Sourcepub fn new(memory_type: MemoryType, content: String, tags: Vec<String>) -> Self
pub fn new(memory_type: MemoryType, content: String, tags: Vec<String>) -> Self
Creates a new memory with a generated ID.
The ID is generated using the current Unix timestamp and random hex characters.
Sourcepub fn generate_id() -> String
pub fn generate_id() -> String
Generates a unique memory ID.
Format: mem-{unix_timestamp}-{4_hex_chars}
Example: mem-1737372000-a1b2
The hex suffix is derived from the microsecond component of the timestamp, providing sufficient uniqueness for typical usage without external dependencies.
Sourcepub fn matches_query(&self, query: &str) -> bool
pub fn matches_query(&self, query: &str) -> bool
Returns true if this memory matches the given search query.
Matches against content and tags (case-insensitive).
Sourcepub fn has_any_tag(&self, tags: &[String]) -> bool
pub fn has_any_tag(&self, tags: &[String]) -> bool
Returns true if this memory has any of the specified tags.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Memory
impl<'de> Deserialize<'de> for Memory
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Memory
impl RefUnwindSafe for Memory
impl Send for Memory
impl Sync for Memory
impl Unpin for Memory
impl UnsafeUnpin for Memory
impl UnwindSafe for Memory
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Erasable for T
impl<T> Erasable for T
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>
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>
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