pub struct StaticTenantResolverBuilder { /* private fields */ }Expand description
Builder for creating a StaticTenantResolver with predefined tenants.
This builder provides a fluent interface for setting up multiple tenants at once, which is useful for testing and initial configuration.
§Example
use scim_server::multi_tenant::StaticTenantResolverBuilder;
use scim_server::{TenantContext, IsolationLevel};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resolver = StaticTenantResolverBuilder::new()
.with_tenant(
"key1",
TenantContext::new("tenant1".to_string(), "client1".to_string())
)
.with_tenant(
"key2",
TenantContext::new("tenant2".to_string(), "client2".to_string())
.with_isolation_level(IsolationLevel::Strict)
)
.build()
.await;
assert_eq!(resolver.tenant_count().await, 2);
Ok(())
}Implementations§
Source§impl StaticTenantResolverBuilder
impl StaticTenantResolverBuilder
Sourcepub fn with_tenant(
self,
credential: &str,
tenant_context: TenantContext,
) -> Self
pub fn with_tenant( self, credential: &str, tenant_context: TenantContext, ) -> Self
Add a tenant to the builder.
Sourcepub async fn build(self) -> StaticTenantResolver
pub async fn build(self) -> StaticTenantResolver
Build the resolver with all configured tenants.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StaticTenantResolverBuilder
impl RefUnwindSafe for StaticTenantResolverBuilder
impl Send for StaticTenantResolverBuilder
impl Sync for StaticTenantResolverBuilder
impl Unpin for StaticTenantResolverBuilder
impl UnwindSafe for StaticTenantResolverBuilder
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> 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.