pub struct AgentStorageManager { /* private fields */ }Expand description
Manages storage instances for multiple agents
Each agent gets its own isolated SQLite database located at:
{tap_root}/{sanitized_did}/transactions.db
Implementations§
Source§impl AgentStorageManager
impl AgentStorageManager
Sourcepub async fn get_agent_storage(
&self,
agent_did: &str,
) -> NodeResult<Arc<Storage>>
pub async fn get_agent_storage( &self, agent_did: &str, ) -> NodeResult<Arc<Storage>>
Get or create storage for an agent
This method maintains a cache of storage instances to avoid recreating databases for the same agent. If the storage doesn’t exist, it creates a new one using the agent’s DID for the database path.
Sourcepub fn get_cached_agent_storage(&self, agent_did: &str) -> Option<Arc<Storage>>
pub fn get_cached_agent_storage(&self, agent_did: &str) -> Option<Arc<Storage>>
Get storage for an agent if it exists in cache (doesn’t create new one)
Sourcepub fn remove_agent_storage(&self, agent_did: &str) -> Option<Arc<Storage>>
pub fn remove_agent_storage(&self, agent_did: &str) -> Option<Arc<Storage>>
Remove an agent’s storage from the cache
This doesn’t delete the database files, just removes the instance from memory. Useful when an agent is unregistered.
Sourcepub fn cached_storage_count(&self) -> usize
pub fn cached_storage_count(&self) -> usize
Get count of cached storage instances
Sourcepub fn cached_agent_dids(&self) -> Vec<String>
pub fn cached_agent_dids(&self) -> Vec<String>
List all agent DIDs that have cached storage
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clear all cached storage instances
This forces recreation of storage instances on next access. Useful for testing or when storage configuration changes.
Sourcepub async fn ensure_agent_storage(&self, agent_did: &str) -> NodeResult<()>
pub async fn ensure_agent_storage(&self, agent_did: &str) -> NodeResult<()>
Ensure storage exists for an agent (creates if needed but doesn’t cache)
This is useful during agent registration to ensure the storage directory and database are properly initialized.
Trait Implementations§
Source§impl Clone for AgentStorageManager
impl Clone for AgentStorageManager
Source§fn clone(&self) -> AgentStorageManager
fn clone(&self) -> AgentStorageManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AgentStorageManager
impl !RefUnwindSafe for AgentStorageManager
impl Send for AgentStorageManager
impl Sync for AgentStorageManager
impl Unpin for AgentStorageManager
impl UnsafeUnpin for AgentStorageManager
impl !UnwindSafe for AgentStorageManager
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more