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.