pub struct TenantQuota {
pub tenant_id: String,
pub max_tuples: usize,
pub max_checks_per_minute: usize,
pub max_api_requests_per_minute: usize,
pub current_tuples: usize,
pub current_checks: usize,
pub current_api_requests: usize,
}Expand description
Tenant quotas and limits
Fields§
§tenant_id: StringTenant identifier
max_tuples: usizeMaximum number of relation tuples
max_checks_per_minute: usizeMaximum permission checks per minute
max_api_requests_per_minute: usizeMaximum API requests per minute
current_tuples: usizeCurrent usage
current_checks: usizeCurrent checks in current window
current_api_requests: usizeCurrent API requests in current window
Implementations§
Source§impl TenantQuota
impl TenantQuota
pub fn new(tenant_id: impl Into<String>) -> Self
pub fn with_max_tuples(self, max: usize) -> Self
pub fn with_max_checks_per_minute(self, max: usize) -> Self
Sourcepub fn can_create_tuple(&self) -> bool
pub fn can_create_tuple(&self) -> bool
Check if tuple creation is allowed
Sourcepub fn can_check_permission(&self) -> bool
pub fn can_check_permission(&self) -> bool
Check if permission check is allowed
Sourcepub fn can_make_api_request(&self) -> bool
pub fn can_make_api_request(&self) -> bool
Check if API request is allowed
Sourcepub fn increment_tuples(&mut self)
pub fn increment_tuples(&mut self)
Increment tuple count
Sourcepub fn decrement_tuples(&mut self)
pub fn decrement_tuples(&mut self)
Decrement tuple count
Sourcepub fn increment_checks(&mut self)
pub fn increment_checks(&mut self)
Increment check count
Sourcepub fn increment_api_requests(&mut self)
pub fn increment_api_requests(&mut self)
Increment API request count
Sourcepub fn reset_rate_limits(&mut self)
pub fn reset_rate_limits(&mut self)
Reset rate limit counters (called every minute)
Trait Implementations§
Source§impl Clone for TenantQuota
impl Clone for TenantQuota
Source§fn clone(&self) -> TenantQuota
fn clone(&self) -> TenantQuota
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 TenantQuota
impl Debug for TenantQuota
Source§impl<'de> Deserialize<'de> for TenantQuota
impl<'de> Deserialize<'de> for TenantQuota
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 TenantQuota
impl RefUnwindSafe for TenantQuota
impl Send for TenantQuota
impl Sync for TenantQuota
impl Unpin for TenantQuota
impl UnwindSafe for TenantQuota
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 more