pub struct Variable {
pub id: VarId,
pub subject: String,
pub key: String,
pub kind: VarKind,
pub verb: String,
pub span: Span,
pub set: Option<String>,
pub shows: Vec<(Option<String>, String)>,
}Expand description
A state of the system: “the kettle is off | heating | dry”.
Fields§
§id: VarId§subject: StringAs declared, e.g. “the kettle”.
key: StringNormalised for matching, e.g. “kettle”.
kind: VarKind§verb: StringThe verb it was declared with, which steps about it read with: “is”, “are”, “has” (“the drawing has 0..100 shapes”) or “have”.
span: Span§set: Option<String>How docs tell the reader to change it, with {value} for the value (“open the dial
to {value}”). Without it: “set the dial to 80 %”.
shows: Vec<(Option<String>, String)>What the reader sees, from Shows: lines: for one value (“dry”, “the display says
DRY”, or “at least 99 %” for a number), or for any value with {value} in it
(None, “the button reads UPLOAD {value}”).
Implementations§
Source§impl Variable
impl Variable
Sourcepub fn shown_shift(&self, shift: Shift) -> Option<String>
pub fn shown_shift(&self, shift: Shift) -> Option<String>
What the reader sees when it’s exactly one value, if a Shows: line says.
What the reader sees when it changes by shift, if a Shows: line says: one keyed
“goes up by 1”, “goes down by 10 m” or “stays the same”, as relative Thens write them.
pub fn shown(&self, c: &Constraint) -> Option<String>
Sourcepub fn full(&self) -> Constraint
pub fn full(&self) -> Constraint
The constraint that allows every value.
pub fn value_index(&self, name: &str) -> Option<usize>
Sourcepub fn witness(&self, c: &Constraint) -> Option<Value>
pub fn witness(&self, c: &Constraint) -> Option<Value>
A concrete value inside c to drive the system with: the first allowed name, or the
middle of a numeric range.
Sourcepub fn admits(&self, c: &Constraint, v: &Value) -> bool
pub fn admits(&self, c: &Constraint, v: &Value) -> bool
Does the observed value satisfy c? Numbers get a tolerance of a millionth of the
state’s range, so a value that went through an f32 still reads as what it was set to.
Sourcepub fn describe(&self, c: &Constraint) -> String
pub fn describe(&self, c: &Constraint) -> String
“the kettle is heating”, “the dial is above 55 %”.
Sourcepub fn predicate(&self, c: &Constraint) -> String
pub fn predicate(&self, c: &Constraint) -> String
“is heating”, “is not dry”, “is between 20 and 40 %” (“are …” for a plural subject).