#[non_exhaustive]pub struct MemoryEntry {
pub id: String,
pub content: String,
pub tags: Vec<String>,
pub source: Option<String>,
pub created_ms: i64,
pub expires_ms: Option<i64>,
}Expand description
One persisted memory record.
Owned (no borrows) so it round-trips through serde and across .await
boundaries cleanly. Fields are intentionally minimal — apps that need
richer schemas can wrap this with their own struct and store JSON in
content.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: StringStable id assigned by the backend. Empty if the caller has not yet committed the entry.
content: StringFree-form fact / summary text. This is what recall returns and what gets injected into a future system prompt.
Optional keywords for cheap retrieval. Backends without semantic
indexing fall back to keyword match across content + tags.
source: Option<String>Where the entry came from (session id, user, app name, …). Useful for debugging and for multi-tenant filtering.
created_ms: i64Milliseconds since unix epoch.
expires_ms: Option<i64>Optional expiry time as milliseconds since unix epoch. None =
retain indefinitely. Backends MUST filter expired entries out of
recall and MAY drop them on a background compact pass.
Use with_ttl_days(N) to set this relative to now. Use None for
stable preferences / identity / long-term project context; use a
finite TTL for ephemeral state (current task params, session-scoped
preferences, …).
Implementations§
Source§impl MemoryEntry
impl MemoryEntry
Sourcepub fn new(content: impl Into<String>) -> MemoryEntry
pub fn new(content: impl Into<String>) -> MemoryEntry
Convenience constructor. The backend assigns id on write.
pub fn with_source(self, source: impl Into<String>) -> MemoryEntry
Sourcepub fn with_ttl_days(self, days: u32) -> MemoryEntry
pub fn with_ttl_days(self, days: u32) -> MemoryEntry
Set expires_ms to “now + days days” using the system clock. For
tests that need a fixed clock, set expires_ms directly.
Sourcepub fn is_expired(&self, now_ms: i64) -> bool
pub fn is_expired(&self, now_ms: i64) -> bool
Returns true if this entry has an expires_ms set and that
timestamp is now in the past. Backends call this from recall and
compact to skip stale entries.
Trait Implementations§
Source§impl Clone for MemoryEntry
impl Clone for MemoryEntry
Source§fn clone(&self) -> MemoryEntry
fn clone(&self) -> MemoryEntry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more