Skip to main content

Gate

Struct Gate 

Source
pub struct Gate<'a> {
    pub requires_flags: &'a [FlagId],
    pub forbids_flags: &'a [FlagId],
    pub requires_state: &'a [StateCompare],
}
Expand description

A gate, as one value: everything that decides whether the thing carrying it may happen.

Borrowed rather than owned, so gate() is free on every consumer and no consumer has to store a second copy of its own fields.

Fields§

§requires_flags: &'a [FlagId]

Flags that must all be set (DSL v0.3/v0.4).

§forbids_flags: &'a [FlagId]

Flags whose being set suppresses this (DSL v0.6).

§requires_state: &'a [StateCompare]

Numeric comparisons that must all hold (DSL v0.10, spec-0031).

Implementations§

Source§

impl<'a> Gate<'a>

Source

pub const OPEN: Gate<'static>

The always-open gate: no flags, no comparison.

Source

pub fn of( requires_flags: &'a [FlagId], forbids_flags: &'a [FlagId], requires_state: &'a [StateCompare], ) -> Self

Build a gate from its three fields. The one constructor, so a consumer that forgets a field is a rustc error rather than a silently narrower gate.

Source

pub fn is_empty(&self) -> bool

True if this gate constrains nothing — the thing carrying it is unconditional, and emission writes it verbatim with no execute wrapper.

Source

pub fn terms(&self) -> usize

How many terms this gate has, across all three axes. The number a binding ledger reports.

Source§

impl Gate<'_>

Source

pub fn contradiction(&self) -> Option<GateContradiction>

The first reason this gate can NEVER open, or None for a satisfiable gate.

A gate is a conjunction, so it is unsatisfiable exactly when one flag is on both lists, or one datum’s terms intersect to the empty set. Terms on distinct flags/datums are independent and cannot contradict each other.

Source

pub fn exclusions(&self, other: &Gate<'_>) -> Vec<GateContradiction>

Every reason this gate and other can never both hold against one reading of the campaign’s flags and data — empty when some state satisfies both.

Two gates are mutually exclusive exactly when their conjunction is a gate that can never open, so this is Gate::contradiction’s arithmetic asked of the two together: a flag one requires and the other forbids, or a datum whose terms across both intersect to the empty set. Nothing else proves exclusivity — two gates on distinct flags or data can both hold, however unlikely the author meant that to be. The answer is about ONE reading: a caller whose two gates are tested at different moments must also show that no write to the named flag or datum falls between them. Every reason is returned, not the first, so that caller can find one nothing writes.

Trait Implementations§

Source§

impl<'a> Clone for Gate<'a>

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<'a> Copy for Gate<'a>

Source§

impl<'a> Debug for Gate<'a>

Source§

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

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

impl<'a> Eq for Gate<'a>

Source§

impl<'a> PartialEq for Gate<'a>

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<'a> StructuralPartialEq for Gate<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Gate<'a>

§

impl<'a> RefUnwindSafe for Gate<'a>

§

impl<'a> Send for Gate<'a>

§

impl<'a> Sync for Gate<'a>

§

impl<'a> Unpin for Gate<'a>

§

impl<'a> UnsafeUnpin for Gate<'a>

§

impl<'a> UnwindSafe for Gate<'a>

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> 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> DynClone for T
where T: Clone,

Source§

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

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> 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.