FieldConditionBuilder

Struct FieldConditionBuilder 

Source
pub struct FieldConditionBuilder<'a, T> { /* private fields */ }
Expand description

Builder for field-based conditions

§Example

use condition_matcher::{FieldConditionBuilder, Matchable, MatchableDerive, RuleMatcher, MatcherMode, Matcher};

#[derive(MatchableDerive, PartialEq)]
struct User {
    age: u32,
}

let condition = FieldConditionBuilder::<User>::new("age").gte(&18u32);

let mut matcher = RuleMatcher::new(MatcherMode::AND);
matcher.add_condition(condition);

let user = User { age: 25 };
assert!(matcher.matches(&user));

Implementations§

Source§

impl<'a, T: Matchable> FieldConditionBuilder<'a, T>

Source

pub fn new(field: &'a str) -> Self

Create a new field condition builder for the given field

Source

pub fn equals(self, value: &'a dyn Any) -> Condition<'a, T>

Field equals value

Source

pub fn not_equals(self, value: &'a dyn Any) -> Condition<'a, T>

Field not equals value

Source

pub fn gt(self, value: &'a dyn Any) -> Condition<'a, T>

Field greater than value

Source

pub fn gte(self, value: &'a dyn Any) -> Condition<'a, T>

Field greater than or equal value

Source

pub fn lt(self, value: &'a dyn Any) -> Condition<'a, T>

Field less than value

Source

pub fn lte(self, value: &'a dyn Any) -> Condition<'a, T>

Field less than or equal value

Source

pub fn contains(self, value: &'a dyn Any) -> Condition<'a, T>

Field contains substring (for string fields)

Source

pub fn starts_with(self, value: &'a dyn Any) -> Condition<'a, T>

Field starts with prefix (for string fields)

Source

pub fn ends_with(self, value: &'a dyn Any) -> Condition<'a, T>

Field ends with suffix (for string fields)

Auto Trait Implementations§

§

impl<'a, T> Freeze for FieldConditionBuilder<'a, T>

§

impl<'a, T> RefUnwindSafe for FieldConditionBuilder<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for FieldConditionBuilder<'a, T>
where T: Send,

§

impl<'a, T> Sync for FieldConditionBuilder<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for FieldConditionBuilder<'a, T>
where T: Unpin,

§

impl<'a, T> UnwindSafe for FieldConditionBuilder<'a, T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.