pub struct CountEvaluator {
pub(crate) counts: Arc<Counts>,
pub(crate) statements: RwLock<Vec<Statement>>,
}Expand description
The engine: the counts it judges against, and every statement compiled into it.
Fields§
§counts: Arc<Counts>§statements: RwLock<Vec<Statement>>Implementations§
Source§impl CountEvaluator
impl CountEvaluator
Sourcepub fn over(counts: Arc<Counts>) -> Self
pub fn over(counts: Arc<Counts>) -> Self
An engine counting into counts instead, for a caller that holds
its own.
pub(crate) fn statement( &self, compiled: CompiledId, ) -> Result<Statement, EvalError>
Sourcepub(crate) fn counted<'a>(
statement: &Statement,
subject: &'a Subject<'a>,
) -> Option<Option<&'a str>>
pub(crate) fn counted<'a>( statement: &Statement, subject: &'a Subject<'a>, ) -> Option<Option<&'a str>>
The account this write counts against for statement, or None
when the statement does not count it: another collection, or a
record that names nobody else when the statement asks for one that
does.
Trait Implementations§
Source§impl Default for CountEvaluator
impl Default for CountEvaluator
Source§impl Evaluator for CountEvaluator
impl Evaluator for CountEvaluator
Source§fn observe(&self, event: &Observed<'_>)
fn observe(&self, event: &Observed<'_>)
Every attempt on the declared surface, admitted or refused, for a statement counting each account. A statement counting the deployment counts only the attempts the policy set allowed.
Source§fn lifecycle(&self, event: &Lifecycle<'_>)
fn lifecycle(&self, event: &Lifecycle<'_>)
A deleted account’s counts go with it. A freeze does not reset a count and an unfreeze does not hand back a spent hour: this engine refuses and never freezes, so there is no freeze here to re-trip.
Source§fn staleness(&self) -> Staleness
fn staleness(&self) -> Staleness
The count is exact and in memory, and every write on the server is routed to a statement counting every collection, so this engine blocks rather than answer from a stale view.
Source§fn compile(&self, predicate: &Value) -> CompileOutcome
fn compile(&self, predicate: &Value) -> CompileOutcome
Source§fn evaluate(
&self,
subject: &Subject<'_>,
compiled: CompiledId,
) -> Result<Outcome, EvalError>
fn evaluate( &self, subject: &Subject<'_>, compiled: CompiledId, ) -> Result<Outcome, EvalError>
subject carries — see this trait’s “What a stateless
predicate may reference” for the boundary the signature enforces.
compiled names the artifact compile
returned for this policy, never [PolicyId] — an evaluator serving
many compiled policies tells them apart by compiled alone; it
never learns PolicyId, which belongs to the caller’s own tree.§fn policy_lifecycle(&self, event: PolicyLifecycle)
fn policy_lifecycle(&self, event: PolicyLifecycle)
PolicyLifecycle]’s doc comment.
Defaulted to a no-op: an evaluator that holds no state per compiled
artifact (this crate’s regex evaluator, most builtins) has nothing
to clean up, and should not be forced to write an empty override
just to say so.