Skip to main content

Gate

Struct Gate 

Source
pub struct Gate { /* private fields */ }
Expand description

A pure decision gate over an ordered list of checks.

Implementations§

Source§

impl Gate

Source

pub fn builder() -> GateBuilder

Start building a gate.

Source

pub fn evaluate(&self, ctx: &ActionContext) -> Decision

Evaluate ctx against the checks in order, under the gate’s Mode.

In Mode::Open (the default) the first check to return Some wins; if none does, the gate allows. Mode::Closed is documented on the variant.

Source

pub fn evaluate_exhaustive(&self, ctx: &ActionContext) -> Evaluation

Evaluate ctx and also collect every deny (spec 004 B-8).

Every check runs exactly once, including those after the deciding one, so a consumer that reports all of its reasons can read them in registration order. The decision is the one Gate::evaluate returns.

Source

pub fn check_ids(&self) -> Vec<&str>

The ids of the registered checks, in evaluation order.

Source

pub fn mode(&self) -> Mode

The gate’s evaluation mode.

Source

pub fn required_ids(&self) -> Vec<&str>

The required check ids, sorted. Empty for an open gate.

Source

pub fn unregistered_required(&self) -> Vec<&str>

The required ids that name no registered check, sorted. A closed gate with any denies every action (closed::REQUIRED_UNREGISTERED); a consumer can call this at startup to refuse the configuration early.

Source

pub fn config_hash(&self) -> String

A stable sha256:<hex> hash of the gate’s configuration.

In Mode::Open it is taken over the canonical JSON array of each check’s config_fingerprint, in order, exactly as in 0.1.0 and 0.2.0, so a recorded hash does not move. In Mode::Closed it is taken over the canonical JSON object {"checks": [...], "mode": "closed", "required": [...]} with the required ids sorted. An object never serializes like an array, so a closed gate never hashes the same as an open one.

Record this in a ledger alongside a decision to prove the decision came from exactly this gate configuration. Because it is order-sensitive and folds in each check’s parameters, a reordered or reconfigured gate hashes differently.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Gate

§

impl !UnwindSafe for Gate

§

impl Forget for Gate

§

impl Freeze for Gate
where *const u8 is !null: Freeze, PhantomData<Box<dyn Check>>: Freeze, *const LeafNode<String, SetValZST> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, SetValZST)>>: Freeze,

§

impl Move for Gate

§

impl Send for Gate
where RawVecInner: Send, BoxRaw<dyn Check>: Send, NodeRef<Owned, String, SetValZST, LeafOrInternal>: Send, BoxRaw<(String, SetValZST)>: Send,

§

impl Sync for Gate
where RawVecInner: Sync, BoxRaw<dyn Check>: Sync, NodeRef<Owned, String, SetValZST, LeafOrInternal>: Sync, BoxRaw<(String, SetValZST)>: Sync,

§

impl Unpin for Gate
where *const u8 is !null: Unpin, Box<dyn Check>: Unpin, *const LeafNode<String, SetValZST> is !null: Unpin, Box<(String, SetValZST)>: Unpin,

§

impl UnsafeUnpin for Gate
where *const u8 is !null: UnsafeUnpin, PhantomData<Box<dyn Check>>: UnsafeUnpin, *const LeafNode<String, SetValZST> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, SetValZST)>>: UnsafeUnpin,

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.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.