pub struct Decision { /* private fields */ }Expand description
The outcome of evaluating one check.
Allowed outcomes report immediately available allowance after the check
and the backend-reported time until full capacity is replenished. Denied
outcomes carry a Denial.
With the serde feature, this is an object tagged by outcome. Invalid
allowed metadata, such as available exceeding capacity, is rejected.
Implementations§
Source§impl Decision
impl Decision
Sourcepub const fn allowed(
capacity: u64,
available: u64,
replenishes_after: Duration,
) -> Self
pub const fn allowed( capacity: u64, available: u64, replenishes_after: Duration, ) -> Self
Constructs an allowed decision.
Storage backends should pass the available allowance after consuming
the check’s cost. This low-level constructor trusts the backend to
ensure available <= capacity.
Sourcepub const fn shadow_denied(denial: Denial) -> Self
pub const fn shadow_denied(denial: Denial) -> Self
Constructs a shadow quota denial.
Backends must use this only for Denial::QuotaExceeded. Storage
capacity remains an enforced denial in every quota mode.
Sourcepub const fn is_allowed(&self) -> bool
pub const fn is_allowed(&self) -> bool
Returns whether the application may proceed.
This includes both consumed allowed decisions and quota denials from a shadow policy.
Sourcepub const fn is_denied(&self) -> bool
pub const fn is_denied(&self) -> bool
Returns whether the application must reject the operation.
Sourcepub const fn permits_request(&self) -> bool
pub const fn permits_request(&self) -> bool
Returns whether the application may proceed.
Sourcepub const fn would_deny(&self) -> bool
pub const fn would_deny(&self) -> bool
Returns whether this check encountered quota or capacity denial.
Sourcepub const fn is_enforced_denial(&self) -> bool
pub const fn is_enforced_denial(&self) -> bool
Returns whether this decision must be enforced.
Sourcepub const fn is_shadow_denied(&self) -> bool
pub const fn is_shadow_denied(&self) -> bool
Returns whether quota was exceeded in shadow mode.
Sourcepub const fn capacity(&self) -> Option<u64>
pub const fn capacity(&self) -> Option<u64>
Returns the configured capacity when it is meaningful for this outcome.
Allowed decisions and quota denials have a capacity. Storage-capacity denials do not.
Sourcepub const fn available(&self) -> Option<u64>
pub const fn available(&self) -> Option<u64>
Returns the immediately available allowance after a consumed check.
Sourcepub const fn replenishes_after(&self) -> Option<Duration>
pub const fn replenishes_after(&self) -> Option<Duration>
Returns when an allowed decision’s full capacity is next available.
Sourcepub const fn retry_after(&self) -> Option<Duration>
pub const fn retry_after(&self) -> Option<Duration>
Returns the backend-reported duration after which a denied check may retry.
Sourcepub const fn retry_after_seconds(&self) -> Option<u64>
pub const fn retry_after_seconds(&self) -> Option<u64>
Returns a whole-second Retry-After value rounded up, if known.
Trait Implementations§
impl Copy for Decision
Source§impl<'de> Deserialize<'de> for Decision
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Decision
serde only.