pub struct DenyByDefault;Expand description
A terminal check that denies whatever reached it (spec 001 B-14).
The gate’s published default is to allow when no check returns Some.
Registering DenyByDefault last closes it instead: an action passes only if
an earlier check returns Some(Decision::allow()). Checks registered after
it never run. It is never added implicitly; see also
GateBuilder::build_deny_by_default.
It belongs to Mode::Open. A Mode::Closed gate does not stop at an
allow, so this check would deny every action there; a closed gate denies
undecided actions by itself.
The deny is blocking, so a trust layer downstream cannot reopen a gate its operator explicitly closed.
use action_gate_core::{ActionContext, Check, Decision, Gate};
struct AllowRead;
impl Check for AllowRead {
fn id(&self) -> &str { "allow-read" }
fn evaluate(&self, ctx: &ActionContext) -> Option<Decision> {
(ctx.action == "read").then(Decision::allow)
}
}
let gate = Gate::builder().check(AllowRead).build_deny_by_default();
assert!(gate.evaluate(&ActionContext::new("read")).is_allow());
assert!(!gate.evaluate(&ActionContext::new("write")).is_allow());Implementations§
Trait Implementations§
Source§impl Check for DenyByDefault
impl Check for DenyByDefault
Source§fn evaluate(&self, _ctx: &ActionContext) -> Option<Decision>
fn evaluate(&self, _ctx: &ActionContext) -> Option<Decision>
Evaluate the context.
Some short-circuits the gate; None passes on.Source§fn config_fingerprint(&self) -> String
fn config_fingerprint(&self) -> String
A stable fingerprint of this check’s identity and parameters, folded
into the gate’s config hash. Defaults to
id; a check with
tunable parameters should override this to include them, so a recorded
decision can be bound to the exact gate configuration that produced it.Source§impl Clone for DenyByDefault
impl Clone for DenyByDefault
impl Copy for DenyByDefault
Source§impl Debug for DenyByDefault
impl Debug for DenyByDefault
Source§impl Default for DenyByDefault
impl Default for DenyByDefault
impl Eq for DenyByDefault
Source§impl PartialEq for DenyByDefault
impl PartialEq for DenyByDefault
impl StructuralPartialEq for DenyByDefault
Auto Trait Implementations§
impl Freeze for DenyByDefault
impl RefUnwindSafe for DenyByDefault
impl Send for DenyByDefault
impl Sync for DenyByDefault
impl Unpin for DenyByDefault
impl UnsafeUnpin for DenyByDefault
impl UnwindSafe for DenyByDefault
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