pub struct Tenant {
pub id: TenantId,
pub metadata: TenantMetadata,
pub status: TenantStatus,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub trial_expires_at: Option<DateTime<Utc>>,
pub namespace: String,
pub config: HashMap<String, String>,
}Expand description
Represents a tenant in the multi-tenant system
Fields§
§id: TenantIdUnique tenant identifier
metadata: TenantMetadataTenant metadata
status: TenantStatusCurrent tenant status
created_at: DateTime<Utc>Tenant creation timestamp
updated_at: DateTime<Utc>Last updated timestamp
trial_expires_at: Option<DateTime<Utc>>Trial expiration (if applicable)
namespace: StringNamespace prefix for data isolation
config: HashMap<String, String>Custom configuration for the tenant
Implementations§
Source§impl Tenant
impl Tenant
Sourcepub fn new(id: impl Into<String>, metadata: TenantMetadata) -> Self
pub fn new(id: impl Into<String>, metadata: TenantMetadata) -> Self
Create a new tenant
Sourcepub fn new_with_auto_id(metadata: TenantMetadata) -> Self
pub fn new_with_auto_id(metadata: TenantMetadata) -> Self
Create a new tenant with auto-generated ID
Sourcepub fn new_trial(
id: impl Into<String>,
metadata: TenantMetadata,
trial_days: u32,
) -> Self
pub fn new_trial( id: impl Into<String>, metadata: TenantMetadata, trial_days: u32, ) -> Self
Create a tenant in trial mode
Sourcepub fn is_operational(&self) -> bool
pub fn is_operational(&self) -> bool
Check if tenant is active and operational
Sourcepub fn is_trial_expired(&self) -> bool
pub fn is_trial_expired(&self) -> bool
Check if trial has expired
Sourcepub fn set_status(&mut self, status: TenantStatus)
pub fn set_status(&mut self, status: TenantStatus)
Update tenant status
Sourcepub fn convert_trial_to_paid(&mut self, new_tier: impl Into<String>)
pub fn convert_trial_to_paid(&mut self, new_tier: impl Into<String>)
Convert trial to paid
Sourcepub fn set_config(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn set_config(&mut self, key: impl Into<String>, value: impl Into<String>)
Set configuration value
Sourcepub fn get_config(&self, key: &str) -> Option<&String>
pub fn get_config(&self, key: &str) -> Option<&String>
Get configuration value
Sourcepub fn namespaced_key(&self, key: &str) -> String
pub fn namespaced_key(&self, key: &str) -> String
Get namespaced key for data isolation
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Tenant
impl<'de> Deserialize<'de> for Tenant
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 Tenant
impl RefUnwindSafe for Tenant
impl Send for Tenant
impl Sync for Tenant
impl Unpin for Tenant
impl UnwindSafe for Tenant
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> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.