Struct foxbox_thinkerbell::ast::Match
[−]
[src]
pub struct Match<Ctx> where Ctx: Context {
pub source: Vec<GetterSelector>,
pub kind: ChannelKind,
pub range: Range,
pub duration: Option<Duration>,
pub phantom: PhantomData<Ctx>,
}
An individual match.
Matchs always take the form: "data received from getter channel enters given range".
A condition is true if any of the corresponding getter channels yielded a value that enters the given range.
JSON
A match is represented as an object with the following fields:
- source (array of GetterSelector) - the selector for getters that will provide the data;
- kind (ChannelKind) - the kind of getters;
- range (Range) - the condition in whih the match is considered met – a match becomes met when any of the sources enters the range;
- duration (Duration, optional) - if provided, the match is only considered
met if any of the sources enters and remains in the range
for
duration
extern crate foxbox_thinkerbell; extern crate foxbox_taxonomy; use foxbox_thinkerbell::ast::*; use foxbox_taxonomy::services::*; use foxbox_taxonomy::parse::*; let source = r#"{ "source": [{"id": "my getter"}], "kind": "OvenTemperature", "range": {"Geq": {"Temperature": {"C": 300}}}, "duration": 3600 }"#; let match_ = Match::<UncheckedCtx>::from_str(&source).unwrap(); assert_eq!(match_.kind, ChannelKind::OvenTemperature);
Fields
source | The set of getters to watch. Note that the set of getters may change (e.g. when devices are added/removed) without rebooting the script. |
kind | The kind of channel expected from |
range | The range of values for which the condition is considered met.
During compilation, we check that the type of |
duration | If specified, the values must remain in the |
phantom |