[−][src]Struct phreak_engine::condition::ConditionBuilder
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
impl RefUnwindSafe for ConditionBuilder
impl Send for ConditionBuilder
impl Sync for ConditionBuilder
impl Unpin for ConditionBuilder
impl UnwindSafe for ConditionBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,