pub struct Rule {
pub name: String,
pub when: Condition,
pub then: Vec<Action>,
pub otherwise: Vec<Action>,
}Expand description
One rule: a condition over a topic, and what to do as it sets and clears.
{
"name": "water-when-dry",
"when": { "topic": "garden/bed-1/moisture", "below": 30.0, "hysteresis": 5.0 },
"then": [ { "drive": "bed-valve", "on": true } ],
"otherwise": [ { "drive": "bed-valve", "on": false } ]
}then runs once when the condition becomes true and otherwise once when it stops
holding; either may be left out. The name is what the engine reports when the rule
fires.
Fields§
§name: StringA stable name for the rule, such as "water-when-dry".
when: ConditionThe condition the rule watches.
then: Vec<Action>What to do the moment the condition becomes true.
otherwise: Vec<Action>What to do the moment the condition stops holding.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Rule
impl<'de> Deserialize<'de> for Rule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Rule
Auto Trait Implementations§
impl Freeze for Rule
impl RefUnwindSafe for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnsafeUnpin for Rule
impl UnwindSafe for Rule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more