pub struct EvaluationContext<UserData> { /* private fields */ }Expand description
Immutable input data for specifications that need counters, flags, time, and application-specific user data.
The context has no interior mutability or global registration mechanism. It
is Send and Sync when UserData and its standard-library fields are,
allowing callers to move or share a context according to the auto-trait
rules of the user data they provide.
Implementations§
Source§impl<UserData> EvaluationContext<UserData>
impl<UserData> EvaluationContext<UserData>
Sourcepub fn with_counter(self, key: impl Into<String>, value: u64) -> Self
pub fn with_counter(self, key: impl Into<String>, value: u64) -> Self
Adds or replaces a counter while constructing the context.
Sourcepub fn with_flag(self, key: impl Into<String>, value: bool) -> Self
pub fn with_flag(self, key: impl Into<String>, value: bool) -> Self
Adds or replaces a flag while constructing the context.
Sourcepub fn with_timestamp(self, key: impl Into<String>, value: Duration) -> Self
pub fn with_timestamp(self, key: impl Into<String>, value: Duration) -> Self
Adds or replaces a timestamp while constructing the context.
Trait Implementations§
Source§impl<UserData> Specification<EvaluationContext<UserData>> for MaxCount
impl<UserData> Specification<EvaluationContext<UserData>> for MaxCount
Source§fn is_satisfied_by(&self, context: &EvaluationContext<UserData>) -> bool
fn is_satisfied_by(&self, context: &EvaluationContext<UserData>) -> bool
Returns whether
candidate satisfies this rule.Source§fn and<Other>(self, other: Other) -> And<Self, Other>where
Self: Sized,
Other: Specification<T>,
fn and<Other>(self, other: Other) -> And<Self, Other>where
Self: Sized,
Other: Specification<T>,
Combines this rule with
other using short-circuiting logical AND. Read moreSource§impl<UserData> Specification<EvaluationContext<UserData>> for Flag
impl<UserData> Specification<EvaluationContext<UserData>> for Flag
Source§fn is_satisfied_by(&self, context: &EvaluationContext<UserData>) -> bool
fn is_satisfied_by(&self, context: &EvaluationContext<UserData>) -> bool
Returns whether
candidate satisfies this rule.Source§fn and<Other>(self, other: Other) -> And<Self, Other>where
Self: Sized,
Other: Specification<T>,
fn and<Other>(self, other: Other) -> And<Self, Other>where
Self: Sized,
Other: Specification<T>,
Combines this rule with
other using short-circuiting logical AND. Read moreSource§impl<UserData, ClockType> Specification<EvaluationContext<UserData>> for Cooldown<ClockType>where
ClockType: Clock,
impl<UserData, ClockType> Specification<EvaluationContext<UserData>> for Cooldown<ClockType>where
ClockType: Clock,
Source§fn is_satisfied_by(&self, context: &EvaluationContext<UserData>) -> bool
fn is_satisfied_by(&self, context: &EvaluationContext<UserData>) -> bool
Returns whether
candidate satisfies this rule.Source§fn and<Other>(self, other: Other) -> And<Self, Other>where
Self: Sized,
Other: Specification<T>,
fn and<Other>(self, other: Other) -> And<Self, Other>where
Self: Sized,
Other: Specification<T>,
Combines this rule with
other using short-circuiting logical AND. Read moreAuto Trait Implementations§
impl<UserData> Freeze for EvaluationContext<UserData>where
UserData: Freeze,
impl<UserData> RefUnwindSafe for EvaluationContext<UserData>where
UserData: RefUnwindSafe,
impl<UserData> Send for EvaluationContext<UserData>where
UserData: Send,
impl<UserData> Sync for EvaluationContext<UserData>where
UserData: Sync,
impl<UserData> Unpin for EvaluationContext<UserData>where
UserData: Unpin,
impl<UserData> UnsafeUnpin for EvaluationContext<UserData>where
UserData: UnsafeUnpin,
impl<UserData> UnwindSafe for EvaluationContext<UserData>where
UserData: UnwindSafe,
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