Skip to main content

CountEvaluator

Struct CountEvaluator 

Source
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

Source

pub fn new() -> Self

An engine counting into this process’s counts().

Source

pub fn over(counts: Arc<Counts>) -> Self

An engine counting into counts instead, for a caller that holds its own.

Source

pub(crate) fn statement( &self, compiled: CompiledId, ) -> Result<Statement, EvalError>

Source

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

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Evaluator for CountEvaluator

Source§

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<'_>)

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

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

Compile a predicate document into a live artifact this evaluator can judge, or say why it cannot. Read more
Source§

fn evaluate( &self, subject: &Subject<'_>, compiled: CompiledId, ) -> Result<Outcome, EvalError>

Given a subject and a compiled artifact, return an outcome, from only what 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)

loaded / superseded / removed, so per-policy state does not outlive the artifact it belongs to — see [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.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more