pub struct Memory {Show 13 fields
pub id: String,
pub memory_type: MemoryType,
pub content: String,
pub agent_id: String,
pub session_id: Option<String>,
pub importance: f32,
pub tags: Vec<String>,
pub metadata: Option<Value>,
pub created_at: u64,
pub last_accessed_at: u64,
pub access_count: u32,
pub ttl_seconds: Option<u64>,
pub expires_at: Option<u64>,
}Expand description
A memory stored by an AI agent
Fields§
§id: String§memory_type: MemoryType§content: String§agent_id: String§session_id: Option<String>§importance: f32§metadata: Option<Value>§created_at: u64§last_accessed_at: u64§access_count: u32§ttl_seconds: Option<u64>§expires_at: Option<u64>Implementations§
Source§impl Memory
impl Memory
Sourcepub fn new(
id: String,
content: String,
agent_id: String,
memory_type: MemoryType,
) -> Self
pub fn new( id: String, content: String, agent_id: String, memory_type: MemoryType, ) -> Self
Create a new memory with current timestamps
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if this memory has expired
Sourcepub fn to_vector_metadata(&self) -> Value
pub fn to_vector_metadata(&self) -> Value
Pack memory fields into metadata for Vector storage
Sourcepub fn to_vector(&self, embedding: Vec<f32>) -> Vector
pub fn to_vector(&self, embedding: Vec<f32>) -> Vector
Convert a Memory to a Vector (for storage layer)
Sourcepub fn from_vector(vector: &Vector) -> Option<Self>
pub fn from_vector(vector: &Vector) -> Option<Self>
Reconstruct a Memory from a Vector’s metadata
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>,
Deserialize this value from the given Serde deserializer. Read more
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
Mutably borrows from an owned value. Read more