Skip to main content

Memory

Struct Memory 

Source
pub struct Memory {
Show 13 fields pub id: Ulid, pub memory_type: MemoryType, pub vector: Vec<f32>, pub content: String, pub metadata: Map<String, Value>, pub agent_id: String, pub session_id: Option<String>, pub scope: Scope, pub created_at: i64, pub accessed_at: i64, pub access_count: u32, pub importance: f32, pub ttl_secs: Option<i64>,
}
Expand description

A single memory entry.

Fields§

§id: Ulid

Time-sortable unique ID.

§memory_type: MemoryType

Cognitive category of this memory.

§vector: Vec<f32>

Embedding of content.

§content: String

The actual text/data of the memory.

§metadata: Map<String, Value>

Free-form structured metadata.

§agent_id: String

Which agent created this memory.

§session_id: Option<String>

Which session produced it (relevant for episodic memory).

§scope: Scope

Visibility scope (private to its agent, or shared).

§created_at: i64

Unix seconds at creation.

§accessed_at: i64

Unix seconds of the most recent retrieval. Updated by recall.

§access_count: u32

How many times this memory has been retrieved.

§importance: f32

Importance in [0.0, 1.0]; higher importance resists decay.

§ttl_secs: Option<i64>

Optional lifetime in seconds. After expiry the memory is skipped by recall and removed by compact.

Implementations§

Source§

impl Memory

Source

pub fn new( content: impl Into<String>, memory_type: MemoryType, vector: Vec<f32>, ) -> Self

Create a new memory with sensible defaults. The ID and timestamps are assigned now; tune the rest with the with_* builders.

Source

pub fn with_agent(self, agent_id: impl Into<String>) -> Self

Set the owning agent.

Source

pub fn with_session(self, session_id: impl Into<String>) -> Self

Set the session ID.

Source

pub fn with_importance(self, importance: f32) -> Self

Set the importance score (clamped to [0,1]).

Source

pub fn with_scope(self, scope: Scope) -> Self

Set the visibility scope.

Source

pub fn with_ttl(self, ttl_secs: i64) -> Self

Attach a TTL in seconds.

Source

pub fn with_meta(self, key: impl Into<String>, value: Value) -> Self

Attach a metadata key/value pair.

Source

pub fn is_expired(&self, now: i64) -> bool

True if the memory’s TTL has elapsed as of now.

Source

pub fn scaffold_manifest(dimensions: usize) -> Self

Build the canonical scaffold manifest for a freshly-initialised database. This is the default “I am a brand-new MNemo file” memory inserted by mnemo init (and surfaced by mnemo about) so every new database is self-describing from birth — no opt-in step required.

The scaffold is a placeholder: the vector is all-zeros (it doesn’t pretend to carry semantic content), and metadata.scaffold = true marks it as auto-generated so tooling and humans can tell it apart from a hand-written manifest. The expected workflow is for the file’s author to replace this memory with one that records the project’s actual embedder, agent_id default, and conventions.

See crate::Mnemo::about for the rest of the convention.

Trait Implementations§

Source§

impl Clone for Memory

Source§

fn clone(&self) -> Memory

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 Memory

Source§

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

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

impl<'de> Deserialize<'de> for Memory

Source§

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

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

impl Serialize for Memory

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V