pub struct StandardResourceProvider<S: StorageProvider> { /* private fields */ }Expand description
Standard resource provider with pluggable storage backend.
This provider separates SCIM protocol logic from storage concerns by delegating data persistence to a StorageProvider implementation while handling all SCIM-specific business logic, validation, and metadata management.
Implementations§
Source§impl<S: StorageProvider> StandardResourceProvider<S>
impl<S: StorageProvider> StandardResourceProvider<S>
Sourcepub async fn clear(&self)
pub async fn clear(&self)
Clear all data from storage.
Removes all resources from all tenants by delegating to the storage backend’s clear operation. This method provides a consistent interface for clearing data regardless of the underlying storage implementation.
§Behavior
- Delegates to
StorageProvider::clearfor actual data removal - Logs warnings if the clear operation fails
- Primarily intended for testing scenarios
- After successful clearing,
get_statsshould report zero resources
§Examples
use scim_server::providers::StandardResourceProvider;
use scim_server::storage::InMemoryStorage;
let storage = InMemoryStorage::new();
let provider = StandardResourceProvider::new(storage);
// ... create some resources ...
provider.clear().await;
let stats = provider.get_stats().await;
assert_eq!(stats.total_resources, 0);Sourcepub async fn get_stats(&self) -> InMemoryStats
pub async fn get_stats(&self) -> InMemoryStats
Get comprehensive statistics about stored data across all tenants.
Dynamically discovers all tenants and resource types from storage to provide accurate statistics without relying on hardcoded patterns. This method uses the storage provider’s discovery capabilities to enumerate actual data.
§Returns
InMemoryStats containing:
tenant_count: Number of tenants with at least one resourcetotal_resources: Sum of all resources across all tenants and typesresource_type_count: Number of distinct resource types foundresource_types: List of all resource type names
§Errors
This method handles storage errors gracefully by using default values (empty collections) when discovery operations fail.
§Examples
use scim_server::providers::StandardResourceProvider;
use scim_server::storage::InMemoryStorage;
use scim_server::resource::{RequestContext, TenantContext};
let storage = InMemoryStorage::new();
let provider = StandardResourceProvider::new(storage);
// ... create resources in multiple tenants ...
let stats = provider.get_stats().await;
println!("Total resources: {}", stats.total_resources);
println!("Active tenants: {}", stats.tenant_count);
println!("Resource types: {:?}", stats.resource_types);Source§impl<S: StorageProvider> StandardResourceProvider<S>
impl<S: StorageProvider> StandardResourceProvider<S>
pub async fn conditional_update( &self, resource_type: &str, id: &str, data: Value, expected_version: &ScimVersion, context: &RequestContext, ) -> Result<ConditionalResult<VersionedResource>, InMemoryError>
pub async fn conditional_delete( &self, resource_type: &str, id: &str, expected_version: &ScimVersion, context: &RequestContext, ) -> Result<ConditionalResult<()>, InMemoryError>
pub async fn conditional_patch_resource( &self, resource_type: &str, id: &str, patch_request: &Value, expected_version: &ScimVersion, context: &RequestContext, ) -> Result<ConditionalResult<VersionedResource>, InMemoryError>
pub async fn get_versioned_resource( &self, resource_type: &str, id: &str, context: &RequestContext, ) -> Result<Option<VersionedResource>, InMemoryError>
pub async fn create_versioned_resource( &self, resource_type: &str, data: Value, context: &RequestContext, ) -> Result<VersionedResource, InMemoryError>
Trait Implementations§
Source§impl<S: Clone + StorageProvider> Clone for StandardResourceProvider<S>
impl<S: Clone + StorageProvider> Clone for StandardResourceProvider<S>
Source§fn clone(&self) -> StandardResourceProvider<S>
fn clone(&self) -> StandardResourceProvider<S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<S: Debug + StorageProvider> Debug for StandardResourceProvider<S>
impl<S: Debug + StorageProvider> Debug for StandardResourceProvider<S>
Source§impl<S: StorageProvider> ResourceProvider for StandardResourceProvider<S>
impl<S: StorageProvider> ResourceProvider for StandardResourceProvider<S>
Source§fn apply_patch_operation(
&self,
resource_data: &mut Value,
operation: &Value,
) -> Result<(), Self::Error>
fn apply_patch_operation( &self, resource_data: &mut Value, operation: &Value, ) -> Result<(), Self::Error>
Override the default patch operation implementation