pub struct NamespaceQuota {
pub namespace: String,
pub limit_bytes: u64,
pub used_bytes: Arc<AtomicU64>,
pub policy: QuotaPolicy,
pub block_count: Arc<AtomicU64>,
}Expand description
Quota state for a single namespace.
Fields§
§namespace: StringIdentifier for this namespace.
limit_bytes: u64Maximum bytes allowed (only meaningful for HardLimit / SoftLimit).
used_bytes: Arc<AtomicU64>Currently consumed bytes (atomic, shared across threads).
policy: QuotaPolicyEnforcement policy.
block_count: Arc<AtomicU64>Number of stored blocks (atomic, shared across threads).
Implementations§
Source§impl NamespaceQuota
impl NamespaceQuota
Sourcepub fn new(namespace: String, limit_bytes: u64, policy: QuotaPolicy) -> Self
pub fn new(namespace: String, limit_bytes: u64, policy: QuotaPolicy) -> Self
Create a new NamespaceQuota.
Sourcepub fn available_bytes(&self) -> u64
pub fn available_bytes(&self) -> u64
Returns how many bytes are still available before the limit is reached.
Uses saturating subtraction, so returns 0 when already over limit.
Sourcepub fn usage_ratio(&self) -> f64
pub fn usage_ratio(&self) -> f64
Returns the fraction of the limit currently used (range [0.0, ∞)).
Returns 0.0 when limit_bytes is 0 to avoid division by zero.
Sourcepub fn is_over_soft_threshold(&self, threshold: f64) -> bool
pub fn is_over_soft_threshold(&self, threshold: f64) -> bool
Returns true when usage_ratio() exceeds threshold.
Auto Trait Implementations§
impl Freeze for NamespaceQuota
impl RefUnwindSafe for NamespaceQuota
impl Send for NamespaceQuota
impl Sync for NamespaceQuota
impl Unpin for NamespaceQuota
impl UnsafeUnpin for NamespaceQuota
impl UnwindSafe for NamespaceQuota
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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