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>
impl<'a> Gate<'a>
Sourcepub fn of(
requires_flags: &'a [FlagId],
forbids_flags: &'a [FlagId],
requires_state: &'a [StateCompare],
) -> Self
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§impl Gate<'_>
impl Gate<'_>
Sourcepub fn contradiction(&self) -> Option<GateContradiction>
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.
Sourcepub fn exclusions(&self, other: &Gate<'_>) -> Vec<GateContradiction>
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.