Struct foxbox_thinkerbell::ast::Statement [] [src]

pub struct Statement<Ctx> where Ctx: Context {
    pub destination: Vec<SetterSelector>,
    pub value: Value,
    pub kind: ChannelKind,
    pub phantom: PhantomData<Ctx>,
}

Stuff to actually do. In practice, this means placing calls to devices.

JSON

A statement is represented as an object with the following fields: - destination (array of SetterSelector); - value (Value); - kind (ChannelKind);

extern crate foxbox_thinkerbell;
extern crate foxbox_taxonomy;

use foxbox_thinkerbell::ast::*;
use foxbox_taxonomy::values::*;
use foxbox_taxonomy::services::*;
use foxbox_taxonomy::parse::*;

let source = r#"{
  "destination": [{"id": "my setter"}],
  "value": {"OnOff": "Off"},
  "kind": "OnOff"
}"#;

let statement = Statement::<UncheckedCtx>::from_str(&source).unwrap();
assert_eq!(statement.value, Value::OnOff(OnOff::Off));
assert_eq!(statement.kind, ChannelKind::OnOff);

Fields

destination

The set of setters to which to send a command. Note that the set of setters may change (e.g. when devices are added/removed) without rebooting the script.

value

Data to send to the resource. During compilation, we check that the type of value is compatible with that of destination.

kind

The kind of channel expected from destination, e.g. "close the door", "set the temperature", etc. During compilation, we make sure that we restrict to the elements of destination that offer kind.

phantom

Trait Implementations

impl Parser<Statement<UncheckedCtx>> for Statement<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>