pub struct TenantContext {
pub tenant_id: TenantId,
pub user_id: Option<UserId>,
pub limits: ResourceLimits,
pub features: HashMap<String, bool>,
pub metadata: HashMap<String, Value>,
}Expand description
TenantContext - Required context for every execution
This is the multi-tenant isolation boundary. Every execution MUST have a TenantContext with a valid TenantId.
Fields§
§tenant_id: TenantIdTenant ID (REQUIRED)
user_id: Option<UserId>User ID (optional - system executions may not have a user)
limits: ResourceLimitsResource limits for this tenant
features: HashMap<String, bool>Tenant-specific feature flags
metadata: HashMap<String, Value>Tenant metadata
Implementations§
Source§impl TenantContext
impl TenantContext
Sourcepub fn with_limits(self, limits: ResourceLimits) -> Self
pub fn with_limits(self, limits: ResourceLimits) -> Self
Set resource limits
Sourcepub fn with_feature(self, feature: impl Into<String>, enabled: bool) -> Self
pub fn with_feature(self, feature: impl Into<String>, enabled: bool) -> Self
Enable a feature flag
Sourcepub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
pub fn with_metadata(self, key: impl Into<String>, value: Value) -> Self
Add metadata
Sourcepub fn is_feature_enabled(&self, feature: &str) -> bool
pub fn is_feature_enabled(&self, feature: &str) -> bool
Check if a feature is enabled
Sourcepub fn child_context(&self, user_id: Option<UserId>) -> Self
pub fn child_context(&self, user_id: Option<UserId>) -> Self
Create a child TenantContext for sub-agent execution (inherits tenant, limits, features but can override user)
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
Auto Trait Implementations§
impl Freeze for TenantContext
impl RefUnwindSafe for TenantContext
impl Send for TenantContext
impl Sync for TenantContext
impl Unpin for TenantContext
impl UnsafeUnpin 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