Skip to main content

PolicySnapshot

Struct PolicySnapshot 

Source
#[non_exhaustive]
pub struct PolicySnapshot { pub default_policy: CommandPolicy, pub forbidden_risk_classes: Vec<RiskClass>, pub max_direct_risk: RiskClass, pub allow_text_resolution_for_low_risk: bool, }
Expand description

Point-in-time policy configuration the reducer evaluates against.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§default_policy: CommandPolicy

Policy for commands the domain did not classify.

§forbidden_risk_classes: Vec<RiskClass>

Risk classes that may never execute (e.g. in a sandbox: everything above ReversibleLowRisk).

§max_direct_risk: RiskClass

Highest risk a command may carry while originating from an untrusted origin such as CommandOrigin::DirectSafeUserAct. Default ReversibleLowRisk (I12).

The setting may only tighten: origin_satisfies refuses anything above ReversibleLowRisk from an untrusted origin whatever the snapshot says.

§allow_text_resolution_for_low_risk: bool

Whether low-risk interactions may be resolved from interpreted text when their stored policy permits it (spec §13.2 rule 8).

Implementations§

Source§

impl PolicySnapshot

Source

pub fn conservative() -> Self

The default snapshot: conservative default policy, nothing forbidden, direct acts up to ReversibleLowRisk, text resolution allowed for low-risk cards.

There is no “fail open” setting: when the policy source cannot be consulted the runtime has no snapshot to consult either and must return PolicyError::Unavailable (I19).

Source

pub fn sandbox() -> Self

A snapshot for sandboxed, reversible domains: everything above ReversibleLowRisk is forbidden (spec §11.4).

Source

pub fn is_risk_forbidden(&self, risk: RiskClass) -> bool

Returns true when the risk class may never execute.

Source

pub fn decide( &self, command_ref: CommandRef, policy: &CommandPolicy, origin: &CommandOrigin, ) -> PolicyDecision

Evaluates one command.

The decision answers two questions: may this command execute with the origin it carries, and if not, which card would authorize it. A policy only somebody other than the end user can satisfy (ConfirmationPolicy::HumanProfessionalReview) names no card at all.

Trait Implementations§

Source§

impl Clone for PolicySnapshot

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PolicySnapshot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PolicySnapshot

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for PolicySnapshot

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for PolicySnapshot

Source§

impl PartialEq for PolicySnapshot

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for PolicySnapshot

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for PolicySnapshot

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.