Skip to main content

MemoryEntry

Struct MemoryEntry 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§id: String

Stable id assigned by the backend. Empty if the caller has not yet committed the entry.

§content: String

Free-form fact / summary text. This is what recall returns and what gets injected into a future system prompt.

§tags: Vec<String>

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: i64

Milliseconds 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

Source

pub fn new(content: impl Into<String>) -> MemoryEntry

Convenience constructor. The backend assigns id on write.

Source

pub fn with_tags( self, tags: impl IntoIterator<Item = impl Into<String>>, ) -> MemoryEntry

Source

pub fn with_source(self, source: impl Into<String>) -> MemoryEntry

Source

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.

Source

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

Source§

fn clone(&self) -> MemoryEntry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryEntry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for MemoryEntry

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<MemoryEntry, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for MemoryEntry

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.