pub struct MemoryService { /* private fields */ }Implementations§
Source§impl MemoryService
impl MemoryService
pub fn new(store: Arc<dyn Store>) -> Self
pub fn with_config(store: Arc<dyn Store>, config: AdmissionConfig) -> Self
Sourcepub async fn store(&self, input: StoreMemoryInput) -> Memory
pub async fn store(&self, input: StoreMemoryInput) -> Memory
Store a new memory.
Runs the admission pipeline before persisting:
- memories that pass all checks are stored as
Active - memories that fail are stored as
Rejected
Sourcepub async fn get(
&self,
memory_id: &MemoryId,
) -> Result<Option<Memory>, MemoryError>
pub async fn get( &self, memory_id: &MemoryId, ) -> Result<Option<Memory>, MemoryError>
Retrieve a memory by ID.
Sourcepub async fn update_content(
&self,
memory_id: &MemoryId,
new_content: String,
) -> Result<(), MemoryError>
pub async fn update_content( &self, memory_id: &MemoryId, new_content: String, ) -> Result<(), MemoryError>
Sourcepub async fn transition_status(
&self,
memory_id: &MemoryId,
new_status: MemoryStatus,
) -> Result<(), MemoryError>
pub async fn transition_status( &self, memory_id: &MemoryId, new_status: MemoryStatus, ) -> Result<(), MemoryError>
Transition memory status.
Valid transitions:
- Candidate → {Scanning, Rejected}
- Scanning → {Verified, Rejected}
- Verified → Active
- Active → {Expired, Rejected}
§Errors
Returns MemoryError::InvalidTransition if the transition is not allowed.
Sourcepub fn is_valid_transition(from: &MemoryStatus, to: &MemoryStatus) -> bool
pub fn is_valid_transition(from: &MemoryStatus, to: &MemoryStatus) -> bool
Check if a status transition is valid.
Sourcepub async fn verify(
&self,
memory_id: &MemoryId,
verifier: AgentId,
) -> Result<(), MemoryError>
pub async fn verify( &self, memory_id: &MemoryId, verifier: AgentId, ) -> Result<(), MemoryError>
Sourcepub async fn query(
&self,
filter: MemoryQuery,
) -> Result<Vec<Memory>, MemoryError>
pub async fn query( &self, filter: MemoryQuery, ) -> Result<Vec<Memory>, MemoryError>
Query memories by filter.
Sourcepub async fn count_by_status(
&self,
) -> Result<HashMap<String, usize>, MemoryError>
pub async fn count_by_status( &self, ) -> Result<HashMap<String, usize>, MemoryError>
Count memories by status.
Auto Trait Implementations§
impl !RefUnwindSafe for MemoryService
impl !UnwindSafe for MemoryService
impl Freeze for MemoryService
impl Send for MemoryService
impl Sync for MemoryService
impl Unpin for MemoryService
impl UnsafeUnpin for MemoryService
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