Skip to main content

Check

Struct Check 

Source
pub struct Check<'a, P: RateLimitPolicy + ?Sized = FixedWindowPolicy> { /* 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, P: RateLimitPolicy + ?Sized> Check<'a, P>

Source

pub const fn new(policy: &'a P, subject: SubjectKey) -> Self

Constructs a check with the default cost of 1.

Source

pub fn with_cost( policy: &'a P, 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 capacity.

Source

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 capacity.

Source

pub const fn policy(&self) -> &'a P

Returns the policy evaluated by this check.

Source

pub const fn subject(&self) -> SubjectKey

Returns the opaque subject key evaluated by this check.

Source

pub fn counter_key(&self) -> CounterKey

Returns the complete logical identity of the stored counter.

Source

pub const fn cost(&self) -> u64

Returns the nonzero quota cost.

Trait Implementations§

Source§

impl<P: RateLimitPolicy + ?Sized> Clone for Check<'_, P>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: RateLimitPolicy + ?Sized> Copy for Check<'_, P>

Source§

impl<'a, P: Debug + RateLimitPolicy + ?Sized> Debug for Check<'a, P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, P: Eq + RateLimitPolicy + ?Sized> Eq for Check<'a, P>

Source§

impl<'a, P: PartialEq + RateLimitPolicy + ?Sized> PartialEq for Check<'a, P>

Source§

fn eq(&self, other: &Check<'a, P>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a, P: PartialEq + RateLimitPolicy + ?Sized> StructuralPartialEq for Check<'a, P>

Auto Trait Implementations§

§

impl<'a, P> Freeze for Check<'a, P>
where P: ?Sized,

§

impl<'a, P> RefUnwindSafe for Check<'a, P>
where P: RefUnwindSafe + ?Sized,

§

impl<'a, P> Send for Check<'a, P>
where P: ?Sized,

§

impl<'a, P> Sync for Check<'a, P>
where P: ?Sized,

§

impl<'a, P> Unpin for Check<'a, P>
where P: ?Sized,

§

impl<'a, P> UnsafeUnpin for Check<'a, P>
where P: ?Sized,

§

impl<'a, P> UnwindSafe for Check<'a, P>
where P: RefUnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.