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§
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
Source§async fn exists(&self, key: StorageKey) -> Result<bool, Self::Error>
async fn exists(&self, key: StorageKey) -> Result<bool, Self::Error>
Check if a resource exists. Read more
Source§async fn count(&self, prefix: StoragePrefix) -> Result<usize, Self::Error>
async fn count(&self, prefix: StoragePrefix) -> Result<usize, Self::Error>
Count the total number of resources matching a prefix. Read more
Source§async fn list_tenants(&self) -> Result<Vec<String>, Self::Error>
async fn list_tenants(&self) -> Result<Vec<String>, Self::Error>
List all tenant IDs that currently have data in storage. Read more
Source§async fn list_resource_types(
&self,
tenant_id: &str,
) -> Result<Vec<String>, Self::Error>
async fn list_resource_types( &self, tenant_id: &str, ) -> Result<Vec<String>, Self::Error>
List all resource types for a specific tenant. 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> 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>
Converts
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>
Converts
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 moreSource§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.