pub struct MemoryItem {
pub id: MemoryId,
pub agent_id: AgentId,
pub content: String,
pub importance: f32,
pub timestamp: DateTime<Utc>,
pub tags: Vec<String>,
pub recall_count: u64,
}Expand description
A single memory record stored for an agent.
Fields§
§id: MemoryIdUnique identifier for this memory.
agent_id: AgentIdThe agent this memory belongs to.
content: StringTextual content of the memory.
importance: f32Importance score in [0.0, 1.0]. Higher = more important.
timestamp: DateTime<Utc>UTC timestamp when this memory was recorded.
Searchable tags attached to this memory.
recall_count: u64Number of times this memory has been recalled. Updated in-place by recall.
Implementations§
Source§impl MemoryItem
impl MemoryItem
Sourcepub fn new(
agent_id: AgentId,
content: impl Into<String>,
importance: f32,
tags: Vec<String>,
) -> Self
pub fn new( agent_id: AgentId, content: impl Into<String>, importance: f32, tags: Vec<String>, ) -> Self
Construct a new MemoryItem with the current timestamp and a random ID.
Sourcepub fn age_hours(&self) -> f64
pub fn age_hours(&self) -> f64
Return the age of this memory in fractional hours since it was recorded.
Returns 0.0 if the current time is somehow before timestamp.
Sourcepub fn word_count(&self) -> usize
pub fn word_count(&self) -> usize
Return the approximate number of whitespace-separated words in the content.
Sourcepub fn content_len(&self) -> usize
pub fn content_len(&self) -> usize
Return the byte length of the content string.
Sourcepub fn add_tag(&mut self, tag: impl Into<String>) -> bool
pub fn add_tag(&mut self, tag: impl Into<String>) -> bool
Add tag to this memory item if it is not already present.
Returns true if the tag was newly added, false if it was already present.
Sourcepub fn remove_tag(&mut self, tag: &str) -> bool
pub fn remove_tag(&mut self, tag: &str) -> bool
Remove tag from this memory item.
Returns true if the tag was found and removed, false if it was not present.
Sourcepub fn is_high_importance(&self, threshold: f32) -> bool
pub fn is_high_importance(&self, threshold: f32) -> bool
Return true if this item’s importance score is strictly above threshold.
Useful for filtering a collection to retain only high-value memories:
let important: Vec<_> = items.iter().filter(|m| m.is_high_importance(0.7)).collect();Trait Implementations§
Source§impl Clone for MemoryItem
impl Clone for MemoryItem
Source§fn clone(&self) -> MemoryItem
fn clone(&self) -> MemoryItem
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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>,
Source§impl Display for MemoryItem
impl Display for MemoryItem
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.