pub struct WorkingMemory { /* private fields */ }Expand description
Working memory for temporary agent data
Implementations§
Source§impl WorkingMemory
impl WorkingMemory
Sourcepub fn new_persistent(storage: Arc<dyn Memory>, session_id: String) -> Self
pub fn new_persistent(storage: Arc<dyn Memory>, session_id: String) -> Self
Create working memory without auto-clear
Sourcepub async fn set(
&self,
key: &str,
value: impl Into<MemoryValue>,
) -> RragResult<()>
pub async fn set( &self, key: &str, value: impl Into<MemoryValue>, ) -> RragResult<()>
Set a value in working memory
Sourcepub async fn get(&self, key: &str) -> RragResult<Option<MemoryValue>>
pub async fn get(&self, key: &str) -> RragResult<Option<MemoryValue>>
Get a value from working memory
Sourcepub async fn delete(&self, key: &str) -> RragResult<bool>
pub async fn delete(&self, key: &str) -> RragResult<bool>
Delete a value from working memory
Sourcepub async fn exists(&self, key: &str) -> RragResult<bool>
pub async fn exists(&self, key: &str) -> RragResult<bool>
Check if a key exists in working memory
Sourcepub async fn clear(&self) -> RragResult<()>
pub async fn clear(&self) -> RragResult<()>
Clear all working memory
Sourcepub async fn keys(&self) -> RragResult<Vec<String>>
pub async fn keys(&self) -> RragResult<Vec<String>>
Get all keys in working memory
Sourcepub async fn set_many(&self, pairs: &[(&str, MemoryValue)]) -> RragResult<()>
pub async fn set_many(&self, pairs: &[(&str, MemoryValue)]) -> RragResult<()>
Set multiple values at once
Sourcepub async fn get_many(
&self,
keys: &[&str],
) -> RragResult<Vec<Option<MemoryValue>>>
pub async fn get_many( &self, keys: &[&str], ) -> RragResult<Vec<Option<MemoryValue>>>
Get multiple values at once
Sourcepub async fn count(&self) -> RragResult<usize>
pub async fn count(&self) -> RragResult<usize>
Get count of items in working memory
Sourcepub fn disable_auto_clear(&mut self)
pub fn disable_auto_clear(&mut self)
Disable auto-clear on drop
Sourcepub fn enable_auto_clear(&mut self)
pub fn enable_auto_clear(&mut self)
Enable auto-clear on drop
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WorkingMemory
impl !RefUnwindSafe for WorkingMemory
impl Send for WorkingMemory
impl Sync for WorkingMemory
impl Unpin for WorkingMemory
impl !UnwindSafe for WorkingMemory
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