pub struct Check<'a> { /* private fields */ }Expand description
One proposed quota charge against a policy and opaque subject.
A newly constructed check has cost 1. Custom costs are validated against the referenced policy so a backend never receives a zero-cost or intrinsically impossible check.
Implementations§
Source§impl<'a> Check<'a>
impl<'a> Check<'a>
Sourcepub const fn new(policy: &'a FixedWindowPolicy, subject: SubjectKey) -> Self
pub const fn new(policy: &'a FixedWindowPolicy, subject: SubjectKey) -> Self
Constructs a check with the default cost of 1.
Sourcepub fn with_cost(
policy: &'a FixedWindowPolicy,
subject: SubjectKey,
cost: u64,
) -> Result<Self, CheckError>
pub fn with_cost( policy: &'a FixedWindowPolicy, subject: SubjectKey, cost: u64, ) -> Result<Self, CheckError>
Validates and constructs a check with a custom cost.
§Errors
Returns an error when cost is zero or exceeds the policy limit.
Sourcepub fn try_with_cost(self, cost: u64) -> Result<Self, CheckError>
pub fn try_with_cost(self, cost: u64) -> Result<Self, CheckError>
Returns this check with a validated custom cost.
§Errors
Returns an error when cost is zero or exceeds the policy limit.
Sourcepub const fn policy(&self) -> &'a FixedWindowPolicy
pub const fn policy(&self) -> &'a FixedWindowPolicy
Returns the policy evaluated by this check.
Sourcepub const fn subject(&self) -> SubjectKey
pub const fn subject(&self) -> SubjectKey
Returns the opaque subject key evaluated by this check.
Sourcepub const fn counter_key(&self) -> CounterKey
pub const fn counter_key(&self) -> CounterKey
Returns the complete logical identity of the stored counter.
Trait Implementations§
impl<'a> Copy for Check<'a>
impl<'a> Eq for Check<'a>
impl<'a> StructuralPartialEq for Check<'a>
Auto Trait Implementations§
impl<'a> Freeze for Check<'a>
impl<'a> RefUnwindSafe for Check<'a>
impl<'a> Send for Check<'a>
impl<'a> Sync for Check<'a>
impl<'a> Unpin for Check<'a>
impl<'a> UnsafeUnpin for Check<'a>
impl<'a> UnwindSafe for Check<'a>
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