pub struct InMemoryStorage { /* private fields */ }Expand description
Thread-safe in-memory storage implementation.
Uses a nested HashMap structure for efficient storage and retrieval:
tenant_id → resource_type → resource_id → data
All operations are async and thread-safe using tokio’s RwLock.
Implementations§
Source§impl InMemoryStorage
impl InMemoryStorage
Sourcepub async fn stats(&self) -> InMemoryStorageStats
pub async fn stats(&self) -> InMemoryStorageStats
Get storage statistics for debugging and monitoring.
Sourcepub async fn list_tenants(&self) -> Vec<String>
pub async fn list_tenants(&self) -> Vec<String>
Get all tenant IDs currently in storage.
Sourcepub async fn list_resource_types(&self, tenant_id: &str) -> Vec<String>
pub async fn list_resource_types(&self, tenant_id: &str) -> Vec<String>
Get all resource types for a specific tenant.
Trait Implementations§
Source§impl Clone for InMemoryStorage
impl Clone for InMemoryStorage
Source§fn clone(&self) -> InMemoryStorage
fn clone(&self) -> InMemoryStorage
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 Default for InMemoryStorage
impl Default for InMemoryStorage
Source§impl StorageProvider for InMemoryStorage
impl StorageProvider for InMemoryStorage
Source§type Error = StorageError
type Error = StorageError
The error type returned by storage operations.
Source§async fn put(&self, key: StorageKey, data: Value) -> Result<Value, Self::Error>
async fn put(&self, key: StorageKey, data: Value) -> Result<Value, Self::Error>
Store data at the specified key and return the stored data. Read more
Source§async fn get(&self, key: StorageKey) -> Result<Option<Value>, Self::Error>
async fn get(&self, key: StorageKey) -> Result<Option<Value>, Self::Error>
Retrieve data by key. Read more
Source§async fn delete(&self, key: StorageKey) -> Result<bool, Self::Error>
async fn delete(&self, key: StorageKey) -> Result<bool, Self::Error>
Delete data by key. Read more
Source§async fn list(
&self,
prefix: StoragePrefix,
offset: usize,
limit: usize,
) -> Result<Vec<(StorageKey, Value)>, Self::Error>
async fn list( &self, prefix: StoragePrefix, offset: usize, limit: usize, ) -> Result<Vec<(StorageKey, Value)>, Self::Error>
List resources matching a prefix with pagination. Read more
Source§async fn find_by_attribute(
&self,
prefix: StoragePrefix,
attribute: &str,
value: &str,
) -> Result<Vec<(StorageKey, Value)>, Self::Error>
async fn find_by_attribute( &self, prefix: StoragePrefix, attribute: &str, value: &str, ) -> Result<Vec<(StorageKey, Value)>, Self::Error>
Find resources by a specific attribute value. Read more
Auto Trait Implementations§
impl Freeze for InMemoryStorage
impl !RefUnwindSafe for InMemoryStorage
impl Send for InMemoryStorage
impl Sync for InMemoryStorage
impl Unpin for InMemoryStorage
impl !UnwindSafe for InMemoryStorage
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> TenantValidator for T
impl<T> TenantValidator for T
Source§fn validate_tenant_context(
&self,
expected_tenant_id: &str,
context: &RequestContext,
) -> Result<(), String>
fn validate_tenant_context( &self, expected_tenant_id: &str, context: &RequestContext, ) -> Result<(), String>
Validate that the context has the expected tenant.
Source§fn validate_single_tenant_context(
&self,
context: &RequestContext,
) -> Result<(), String>
fn validate_single_tenant_context( &self, context: &RequestContext, ) -> Result<(), String>
Validate that the context is for single-tenant operation.
Source§fn require_tenant_context(&self, context: &RequestContext) -> Result<(), String>
fn require_tenant_context(&self, context: &RequestContext) -> Result<(), String>
Extract tenant context or return error for multi-tenant operations.