pub struct TenantContext {
pub tenant_id: String,
pub client_id: String,
pub isolation_level: IsolationLevel,
pub permissions: TenantPermissions,
}Expand description
Tenant context for multi-tenant operations
Fields§
§tenant_id: String§client_id: String§isolation_level: IsolationLevel§permissions: TenantPermissionsImplementations§
Source§impl TenantContext
impl TenantContext
Sourcepub fn new(tenant_id: String, client_id: String) -> Self
pub fn new(tenant_id: String, client_id: String) -> Self
Create a new tenant context with default permissions
Sourcepub fn with_isolation_level(self, level: IsolationLevel) -> Self
pub fn with_isolation_level(self, level: IsolationLevel) -> Self
Create a tenant context with custom isolation level
Sourcepub fn with_permissions(self, permissions: TenantPermissions) -> Self
pub fn with_permissions(self, permissions: TenantPermissions) -> Self
Create a tenant context with custom permissions
Sourcepub fn can_perform_operation(&self, operation: &str) -> bool
pub fn can_perform_operation(&self, operation: &str) -> bool
Check if the tenant has permission for a specific operation
Sourcepub fn check_user_limit(&self, current_count: usize) -> bool
pub fn check_user_limit(&self, current_count: usize) -> bool
Check if tenant has reached user limit
Sourcepub fn check_group_limit(&self, current_count: usize) -> bool
pub fn check_group_limit(&self, current_count: usize) -> bool
Check if tenant has reached group limit
Trait Implementations§
Source§impl Clone for TenantContext
impl Clone for TenantContext
Source§fn clone(&self) -> TenantContext
fn clone(&self) -> TenantContext
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 Debug for TenantContext
impl Debug for TenantContext
Source§impl<'de> Deserialize<'de> for TenantContext
impl<'de> Deserialize<'de> for TenantContext
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for TenantContext
impl PartialEq for TenantContext
Source§impl Serialize for TenantContext
impl Serialize for TenantContext
impl Eq for TenantContext
impl StructuralPartialEq for TenantContext
Auto Trait Implementations§
impl Freeze for TenantContext
impl RefUnwindSafe for TenantContext
impl Send for TenantContext
impl Sync for TenantContext
impl Unpin for TenantContext
impl UnwindSafe for TenantContext
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.