Struct foxbox_thinkerbell::ast::Rule
[−]
[src]
pub struct Rule<Ctx> where Ctx: Context {
pub conditions: Vec<Match<Ctx>>,
pub execute: Vec<Statement<Ctx>>,
pub phantom: PhantomData<Ctx>,
}
A single rule, i.e. "when some condition becomes true, do something".
JSON
A single rule is represented as an object with the following fields:
- conditions (array of Match): the conditions in which to execute the code – all conditions must be met;
- execute (array of Statement): the code to execute once all conditions are met.
extern crate foxbox_thinkerbell; extern crate foxbox_taxonomy; use foxbox_thinkerbell::ast::*; use foxbox_taxonomy::parse::*; let source = r#"{ "conditions": [{ "source": [{"id": "my getter"}], "kind": "OvenTemperature", "range": {"Geq": {"Temperature": {"C": 300}}}, "duration": 3600 }], "execute": [{ "destination": [{"id": "my setter"}], "value": {"OnOff": "Off"}, "kind": "OnOff" }] }"#; Rule::<UncheckedCtx>::from_str(&source).unwrap();
Fields
conditions | The condition in which to execute the trigger. The condition
is matched once all the |
execute | Stuff to do once |
phantom |