[][src]Struct phreak_engine::condition::ConditionBuilder

pub struct ConditionBuilder { /* fields omitted */ }

The ConditionBuilder is a helper to create Conditions.

Examples

We create a rule for the presence of a thing that is green and not small, and the abscence of an other thing, which is blue and large. Both condition must apply before this rule matches.


let mut conditions: Vec<Condition> = Vec::new();
let mut subconditions: Vec<Condition> = Vec::new();

let condition =
    ConditionBuilder::new(String::from("car"))
        // default is positive()
        .variable_field1(String::from("a"))
        .const_field2(String::from("is"))
        .const_field3(String::from("green"))
        .build();
conditions.push(condition);

let condition =
    ConditionBuilder::new(String::from("car"))
        .negative(String::from("car"))
        .variable_field1(String::from("a"))
        .const_field2(String::from("is"))
        .const_field3(String::from("small"))
        .build();
conditions.push(condition);

let subcondition =
    ConditionBuilder::new(String::from("car"))
        .variable_field1(String::from("b"))
        .const_field2(String::from("is"))
        .const_field3(String::from("blue"))
        .build();
subconditions.push(subcondition);

let subcondition =
    ConditionBuilder::new(String::from("car"))
        .variable_field1(String::from("b"))
        .const_field2(String::from("is"))
        .const_field3(String::from("large"))
        .build();
subconditions.push(subcondition);

let condition =
    ConditionBuilder::new(String::from("car"))
        .ncc(subconditions)
        .build();
conditions.push(condition);

Methods

impl ConditionBuilder[src]

pub fn new(class: String) -> ConditionBuilder[src]

pub fn positive(self, class: String) -> ConditionBuilder[src]

pub fn negative(self, class: String) -> ConditionBuilder[src]

pub fn ncc(self, tests: Vec<Condition>) -> ConditionBuilder[src]

pub fn field1(self, a_field: ConditionField) -> ConditionBuilder[src]

pub fn field2(self, a_field: ConditionField) -> ConditionBuilder[src]

pub fn field3(self, a_field: ConditionField) -> ConditionBuilder[src]

pub fn const_field1(self, a_field: String) -> ConditionBuilder[src]

pub fn const_field2(self, a_field: String) -> ConditionBuilder[src]

pub fn const_field3(self, a_field: String) -> ConditionBuilder[src]

pub fn variable_field1(self, a_field: String) -> ConditionBuilder[src]

pub fn variable_field2(self, a_field: String) -> ConditionBuilder[src]

pub fn variable_field3(self, a_field: String) -> ConditionBuilder[src]

pub fn build(self) -> Condition[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.