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:

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 Match branches are true. Whenever conditions was false and becomes true, we execute execute.

execute

Stuff to do once condition is met.

phantom

Trait Implementations

impl Parser<Rule<UncheckedCtx>> for Rule<UncheckedCtx>

fn description() -> String

fn parse(path: Path, source: &mut JSON) -> Result<Self, ParseError>

fn from_str(source: &str) -> Result<T, ParseError>

fn take(path: Path, source: &mut Value, field_name: &str) -> Result<T, ParseError>

fn take_opt(path: Path, source: &mut Value, field_name: &str) -> Option<Result<T, ParseError>>

fn take_vec_opt(path: Path, source: &mut Value, field_name: &str) -> Option<Result<Vec<T>, ParseError>>

fn take_vec(path: Path, source: &mut Value, field_name: &str) -> Result<Vec<T>, ParseError>