pub struct MemoryItem {
pub id: String,
pub content: String,
pub timestamp: DateTime<Utc>,
pub importance: f32,
pub tags: Vec<String>,
pub memory_type: MemoryType,
pub metadata: HashMap<String, String>,
pub access_count: u32,
pub last_accessed: Option<DateTime<Utc>>,
pub content_lower: String,
}Expand description
A single memory item
Fields§
§id: StringUnique identifier
content: StringMemory content
timestamp: DateTime<Utc>When this memory was created
importance: f32Importance score (0.0 - 1.0)
Tags for categorization
memory_type: MemoryTypeMemory type
metadata: HashMap<String, String>Associated metadata
access_count: u32Number of times this memory was accessed
last_accessed: Option<DateTime<Utc>>Last access time
content_lower: StringCached lowercase content for fast substring search
Implementations§
Source§impl MemoryItem
impl MemoryItem
Sourcepub fn with_importance(self, importance: f32) -> Self
pub fn with_importance(self, importance: f32) -> Self
Set importance
Add tags
Sourcepub fn with_type(self, memory_type: MemoryType) -> Self
pub fn with_type(self, memory_type: MemoryType) -> Self
Set memory type
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add metadata
Sourcepub fn record_access(&mut self)
pub fn record_access(&mut self)
Record access
Sourcepub fn relevance_score_at(&self, now: DateTime<Utc>) -> f32
pub fn relevance_score_at(&self, now: DateTime<Utc>) -> f32
Calculate relevance score at a given timestamp
Use this variant in sort comparators to avoid repeated Utc::now() syscalls.
Sourcepub fn relevance_score(&self) -> f32
pub fn relevance_score(&self) -> f32
Calculate relevance score based on recency and importance
Trait Implementations§
Source§impl Clone for MemoryItem
impl Clone for MemoryItem
Source§fn clone(&self) -> MemoryItem
fn clone(&self) -> MemoryItem
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 MemoryItem
impl Debug for MemoryItem
Source§impl<'de> Deserialize<'de> for MemoryItem
impl<'de> Deserialize<'de> for MemoryItem
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 MemoryItem
impl RefUnwindSafe for MemoryItem
impl Send for MemoryItem
impl Sync for MemoryItem
impl Unpin for MemoryItem
impl UnsafeUnpin for MemoryItem
impl UnwindSafe for MemoryItem
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