pub struct MemoryEntry {
pub id: String,
pub content: String,
pub metadata: HashMap<String, Value>,
pub embedding: Option<Vec<f32>>,
pub created_at: DateTime<Utc>,
pub expires_at: Option<DateTime<Utc>>,
}Expand description
Entry stored in memory
Fields§
§id: StringUnique identifier
content: StringContent to store
metadata: HashMap<String, Value>Optional metadata for filtering
embedding: Option<Vec<f32>>Optional embedding vector for semantic search
created_at: DateTime<Utc>Timestamp when created
expires_at: Option<DateTime<Utc>>Optional expiration time (TTL)
Implementations§
Source§impl MemoryEntry
impl MemoryEntry
Sourcepub fn with_id(id: impl Into<String>, content: impl Into<String>) -> Self
pub fn with_id(id: impl Into<String>, content: impl Into<String>) -> Self
Create with specific ID
Sourcepub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
pub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
Add metadata
Sourcepub fn with_embedding(self, embedding: Vec<f32>) -> Self
pub fn with_embedding(self, embedding: Vec<f32>) -> Self
Set embedding vector
Sourcepub fn with_expiration(self, expires_at: DateTime<Utc>) -> Self
pub fn with_expiration(self, expires_at: DateTime<Utc>) -> Self
Set expiration time
Sourcepub fn with_ttl_seconds(self, seconds: i64) -> Self
pub fn with_ttl_seconds(self, seconds: i64) -> Self
Set TTL in seconds from now
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if entry has expired
Trait Implementations§
Source§impl Clone for MemoryEntry
impl Clone for MemoryEntry
Source§fn clone(&self) -> MemoryEntry
fn clone(&self) -> MemoryEntry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MemoryEntry
impl Debug for MemoryEntry
Source§impl<'de> Deserialize<'de> for MemoryEntry
impl<'de> Deserialize<'de> for MemoryEntry
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 MemoryEntry
impl RefUnwindSafe for MemoryEntry
impl Send for MemoryEntry
impl Sync for MemoryEntry
impl Unpin for MemoryEntry
impl UnwindSafe for MemoryEntry
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