Predicate

Enum Predicate 

Source
pub enum Predicate {
Show 43 variants Always, Never, And(Vec<Predicate>), Any(Box<Predicate>), Contains(Value), ContainsAll(Vec<Value>), ContainsAny(Vec<Value>), Equals(Value), GreaterThan(Value), GreaterThanOrEquals(Value), HasKey(String), HasKeyWhereValue(String, Box<Predicate>), InRange(RangeInclusive<Value>), InSet(HashSet<Value>), IsNone, Lambda(Rc<dyn Fn(&Value) -> bool>), LessThan(Value), LessThanOrEquals(Value), Not(Box<Predicate>), NotEquals(Value), NotInRange(RangeInclusive<Value>), NotInSet(HashSet<Value>), NotNoneAnd(Box<Predicate>), NoneOr(Box<Predicate>), Or(Vec<Predicate>), TextContainedIn(String), TextContainedInCaseInsensitive(String), TextContainsAll(Vec<String>), TextContainsAllCaseInsensitive(Vec<String>), TextContainsAny(Vec<String>), TextContainsAnyCaseInsensitive(Vec<String>), TextEndsWith(String), TextEndsWithCaseInsensitive(String), TextEndsWithAny(Vec<String>), TextEndsWithAnyCaseInsensitive(Vec<String>), TextEqualsCaseInsensitive(String), TextNotEqualsCaseInsensitive(String), TextInSetCaseInsensitive(HashSet<String>), TextStartsWith(String), TextStartsWithCaseInsensitive(String), TextStartsWithAny(Vec<String>), TextStartsWithAnyCaseInsensitive(Vec<String>), Xor(Vec<Predicate>),
}
Expand description

Represents an untyped predicate that can be used to inspect a value for some specified condition

Variants§

§

Always

Will always be true (not same as equals(true))

§Examples
use entity::{Predicate, ValueLike};
let v = 123.into_value();

let p = Predicate::Always;
assert_eq!(p.check(&v), true);
§

Never

Will always be false (not same as equals(false))

use entity::{Predicate, ValueLike};
let v = 123.into_value();

let p = Predicate::Never;
assert_eq!(p.check(&v), false);
§

And(Vec<Predicate>)

Will be true if all predicates return true against the checked value

§Examples
use entity::{Predicate, Value, ValueLike};
let v = 123.into_value();

let p = Predicate::And(vec![
    Predicate::GreaterThan(122.into_value()),
    Predicate::LessThan(124.into_value()),
]);
assert_eq!(p.check(&v), true);

let p = Predicate::And(vec![
    Predicate::GreaterThan(122.into_value()),
    Predicate::Never,
]);
assert_eq!(p.check(&v), false);

let p = Predicate::And(vec![
    Predicate::Never,
    Predicate::GreaterThan(122.into_value()),
]);
assert_eq!(p.check(&v), false);

let p = Predicate::And(vec![
    Predicate::Never,
    Predicate::Never,
]);
assert_eq!(p.check(&v), false);
§

Any(Box<Predicate>)

Will be true if checked value is a collection where any element satisifies the predicate

§Examples
use entity::{Predicate, Value, ValueLike};
let v = vec![1, 2, 3].into_value();

let p = Predicate::Any(Box::new(Predicate::Equals(2.into_value())));
assert_eq!(p.check(&v), true);

let p = Predicate::Any(Box::new(Predicate::Equals(999.into_value())));
assert_eq!(p.check(&v), false);

Also supports checking values of a map:

use entity::{Predicate, Value, ValueLike};
use std::collections::HashMap;
let map: HashMap<String, u32> = vec![
    (String::from("a"), 1),
    (String::from("b"), 2),
    (String::from("c"), 3),
].into_iter().collect();
let v = map.into_value();

let p = Predicate::Any(Box::new(Predicate::Equals(2.into_value())));
assert_eq!(p.check(&v), true);

let p = Predicate::Any(Box::new(Predicate::Equals(999.into_value())));
assert_eq!(p.check(&v), false);
§

Contains(Value)

Will be true if checked value is a collection that contains the specified value

§Examples
use entity::{Predicate, Value, ValueLike};
let v = vec![1, 2, 3].into_value();

let p = Predicate::Contains(2.into_value());
assert_eq!(p.check(&v), true);

let p = Predicate::Contains(999.into_value());
assert_eq!(p.check(&v), false);

Also supports checking values of a map:

use entity::{Predicate, Value, ValueLike};
use std::collections::HashMap;
let map: HashMap<String, u32> = vec![
    (String::from("a"), 1),
    (String::from("b"), 2),
    (String::from("c"), 3),
].into_iter().collect();
let v = map.into_value();

let p = Predicate::Contains(2.into_value());
assert_eq!(p.check(&v), true);

let p = Predicate::Contains(999.into_value());
assert_eq!(p.check(&v), false);
§

ContainsAll(Vec<Value>)

Will be true if checked value is a collection that contains all of the specified values

§Examples
use entity::{Predicate, Value, ValueLike};
let v = vec![1, 2, 3].into_value();

let p = Predicate::ContainsAll(vec![2.into_value(), 3.into_value()]);
assert_eq!(p.check(&v), true);

let p = Predicate::ContainsAll(vec![2.into_value(), 999.into_value()]);
assert_eq!(p.check(&v), false);

Also supports checking values of a map:

use entity::{Predicate, Value, ValueLike};
use std::collections::HashMap;
let map: HashMap<String, u32> = vec![
    (String::from("a"), 1),
    (String::from("b"), 2),
    (String::from("c"), 3),
].into_iter().collect();
let v = map.into_value();

let p = Predicate::ContainsAll(vec![2.into_value(), 3.into_value()]);
assert_eq!(p.check(&v), true);

let p = Predicate::ContainsAll(vec![2.into_value(), 999.into_value()]);
assert_eq!(p.check(&v), false);
§

ContainsAny(Vec<Value>)

Will be true if checked value is a collection that contains any of the specified values

§Examples
use entity::{Predicate, Value, ValueLike};
let v = vec![1, 2, 3].into_value();

let p = Predicate::ContainsAny(vec![2.into_value(), 999.into_value()]);
assert_eq!(p.check(&v), true);

let p = Predicate::ContainsAny(vec![998.into_value(), 999.into_value()]);
assert_eq!(p.check(&v), false);

Also supports checking values of a map:

use entity::{Predicate, Value, ValueLike};
use std::collections::HashMap;
let map: HashMap<String, u32> = vec![
    (String::from("a"), 1),
    (String::from("b"), 2),
    (String::from("c"), 3),
].into_iter().collect();
let v = map.into_value();

let p = Predicate::ContainsAny(vec![2.into_value(), 999.into_value()]);
assert_eq!(p.check(&v), true);

let p = Predicate::ContainsAny(vec![998.into_value(), 999.into_value()]);
assert_eq!(p.check(&v), false);
§

Equals(Value)

Will be true if checked value equals the specified value

§Examples
use entity::{Predicate, Value, ValueLike};
let v = 123.into_value();

let p = Predicate::Equals(123.into_value());
assert_eq!(p.check(&v), true);

let p = Predicate::Equals(456.into_value());
assert_eq!(p.check(&v), false);
§

GreaterThan(Value)

Will be true if checked value is greater than the specified value

§Examples
use entity::{Predicate, Value, ValueLike};
let v = 123.into_value();

let p = Predicate::GreaterThan(100.into_value());
assert_eq!(p.check(&v), true);

let p = Predicate::GreaterThan(123.into_value());
assert_eq!(p.check(&v), false);

let p = Predicate::GreaterThan(456.into_value());
assert_eq!(p.check(&v), false);
§

GreaterThanOrEquals(Value)

Will be true if checked value is greater than or equals the specified value

§Examples
use entity::{Predicate, Value, ValueLike};
let v = 123.into_value();

let p = Predicate::GreaterThanOrEquals(100.into_value());
assert_eq!(p.check(&v), true);

let p = Predicate::GreaterThanOrEquals(123.into_value());
assert_eq!(p.check(&v), true);

let p = Predicate::GreaterThanOrEquals(456.into_value());
assert_eq!(p.check(&v), false);
§

HasKey(String)

Will be true if checked value is a map that contains the specified key

§Examples
use entity::{Predicate, Value, ValueLike};
use std::collections::HashMap;
let map: HashMap<String, u32> = vec![
    (String::from("a"), 1),
    (String::from("b"), 2),
    (String::from("c"), 3),
].into_iter().collect();
let v = map.into_value();

let p = Predicate::HasKey(String::from("a"));
assert_eq!(p.check(&v), true);

let p = Predicate::HasKey(String::from("d"));
assert_eq!(p.check(&v), false);
§

HasKeyWhereValue(String, Box<Predicate>)

Will be true if checked value is a map that contains the specified key and corresponding value meets the specified predicate

§Examples
use entity::{Predicate, Value, ValueLike};
use std::collections::HashMap;
let map: HashMap<String, u32> = vec![
    (String::from("a"), 1),
    (String::from("b"), 2),
    (String::from("c"), 3),
].into_iter().collect();
let v = map.into_value();

let p = Predicate::HasKeyWhereValue(
    String::from("a"),
    Box::new(Predicate::Equals(1.into_value())),
);
assert_eq!(p.check(&v), true);

let p = Predicate::HasKeyWhereValue(
    String::from("b"),
    Box::new(Predicate::Equals(1.into_value())),
);
assert_eq!(p.check(&v), false);

let p = Predicate::HasKeyWhereValue(
    String::from("d"),
    Box::new(Predicate::Equals(1.into_value())),
);
assert_eq!(p.check(&v), false);
§

InRange(RangeInclusive<Value>)

Will be true if checked value is within the specified range

§Examples
use entity::{Predicate, Value, ValueLike};
let v = 123.into_value();

let p = Predicate::InRange(100.into_value()..=200.into_value());
assert_eq!(p.check(&v), true);

let p = Predicate::InRange(200.into_value()..=300.into_value());
assert_eq!(p.check(&v), false);
§

InSet(HashSet<Value>)

Will be true if checked value is within the specified set

§Examples
use entity::{Predicate, Value, ValueLike};
let v = 123.into_value();

let p = Predicate::InSet(vec![
    122.into_value(),
    123.into_value(),
    124.into_value(),
].into_iter().collect());
assert_eq!(p.check(&v), true);

let p = Predicate::InSet(vec![
    222.into_value(),
    223.into_value(),
    224.into_value(),
].into_iter().collect());
assert_eq!(p.check(&v), false);
§

IsNone

Will be true if checked value optional and is none

§Examples
use entity::{Predicate, Value, ValueLike};

let v = None::<u8>.into_value();
let p = Predicate::IsNone;
assert_eq!(p.check(&v), true);

let v = Some(123).into_value();
let p = Predicate::IsNone;
assert_eq!(p.check(&v), false);
§

Lambda(Rc<dyn Fn(&Value) -> bool>)

Will be true if checked value passes the lambda function by having it return true

§Examples
use entity::{Predicate, Value, ValueLike};
use std::rc::Rc;
let v = 123.into_value();

let p = Predicate::Lambda(Rc::new(|v| v == &123.into_value()));
assert_eq!(p.check(&v), true);

let p = Predicate::Lambda(Rc::new(|v| v == &456.into_value()));
assert_eq!(p.check(&v), false);
§

LessThan(Value)

Will be true if checked value is less than the specified value

§Examples
use entity::{Predicate, Value, ValueLike};
let v = 123.into_value();

let p = Predicate::LessThan(200.into_value());
assert_eq!(p.check(&v), true);

let p = Predicate::LessThan(123.into_value());
assert_eq!(p.check(&v), false);

let p = Predicate::LessThan(100.into_value());
assert_eq!(p.check(&v), false);
§

LessThanOrEquals(Value)

Will be true if checked value is less than or equals the specified value

§Examples
use entity::{Predicate, Value, ValueLike};
let v = 123.into_value();

let p = Predicate::LessThanOrEquals(200.into_value());
assert_eq!(p.check(&v), true);

let p = Predicate::LessThanOrEquals(123.into_value());
assert_eq!(p.check(&v), true);

let p = Predicate::LessThanOrEquals(100.into_value());
assert_eq!(p.check(&v), false);
§

Not(Box<Predicate>)

Will be true if checked value is does not pass the specified predicate

§Examples
use entity::{Predicate, Value, ValueLike};
let v = 123.into_value();

let p = Predicate::Not(Box::new(Predicate::Equals(200.into_value())));
assert_eq!(p.check(&v), true);

let p = Predicate::Not(Box::new(Predicate::Equals(123.into_value())));
assert_eq!(p.check(&v), false);
§

NotEquals(Value)

Will be true if checked value does not equal the specified value

§Examples
use entity::{Predicate, Value, ValueLike};
let v = 123.into_value();

let p = Predicate::NotEquals(456.into_value());
assert_eq!(p.check(&v), true);

let p = Predicate::NotEquals(123.into_value());
assert_eq!(p.check(&v), false);
§

NotInRange(RangeInclusive<Value>)

Will be true if checked value is not within the specified range

§Examples
use entity::{Predicate, Value, ValueLike};
let v = 123.into_value();

let p = Predicate::NotInRange(200.into_value()..=300.into_value());
assert_eq!(p.check(&v), true);

let p = Predicate::NotInRange(100.into_value()..=200.into_value());
assert_eq!(p.check(&v), false);
§

NotInSet(HashSet<Value>)

Will be true if checked value is not within the specified set

§Examples
use entity::{Predicate, Value, ValueLike};
let v = 123.into_value();

let p = Predicate::NotInSet(vec![
    222.into_value(),
    223.into_value(),
    224.into_value(),
].into_iter().collect());
assert_eq!(p.check(&v), true);

let p = Predicate::NotInSet(vec![
    122.into_value(),
    123.into_value(),
    124.into_value(),
].into_iter().collect());
assert_eq!(p.check(&v), false);
§

NotNoneAnd(Box<Predicate>)

Will be true if checked value is not none and passes the specified predicate

§Examples
use entity::{Predicate, Value, ValueLike};

let v = Some(123).into_value();
let p = Predicate::NotNoneAnd(Box::new(Predicate::Equals(123.into_value())));
assert_eq!(p.check(&v), true);

let v = 123.into_value();
let p = Predicate::NotNoneAnd(Box::new(Predicate::Equals(123.into_value())));
assert_eq!(p.check(&v), true);

let v = Some(456).into_value();
let p = Predicate::NotNoneAnd(Box::new(Predicate::Equals(123.into_value())));
assert_eq!(p.check(&v), false);

let v = 456.into_value();
let p = Predicate::NotNoneAnd(Box::new(Predicate::Equals(123.into_value())));
assert_eq!(p.check(&v), false);

let v = None::<u8>.into_value();
let p = Predicate::NotNoneAnd(Box::new(Predicate::Equals(123.into_value())));
assert_eq!(p.check(&v), false);
§

NoneOr(Box<Predicate>)

Will be true if checked value is either none or passes the specified predicate

§Examples
use entity::{Predicate, Value, ValueLike};

let v = None::<u8>.into_value();
let p = Predicate::NoneOr(Box::new(Predicate::Equals(123.into_value())));
assert_eq!(p.check(&v), true);

let v = Some(123).into_value();
let p = Predicate::NoneOr(Box::new(Predicate::Equals(123.into_value())));
assert_eq!(p.check(&v), true);

let v = 123.into_value();
let p = Predicate::NoneOr(Box::new(Predicate::Equals(123.into_value())));
assert_eq!(p.check(&v), true);

let v = Some(456).into_value();
let p = Predicate::NoneOr(Box::new(Predicate::Equals(123.into_value())));
assert_eq!(p.check(&v), false);
§

Or(Vec<Predicate>)

Will be true if any predicate returns true against the checked value

§Examples
use entity::{Predicate, Value, ValueLike};
let v = 123.into_value();

let p = Predicate::Or(vec![
    Predicate::GreaterThan(122.into_value()),
    Predicate::LessThan(124.into_value()),
]);
assert_eq!(p.check(&v), true);

let p = Predicate::Or(vec![
    Predicate::Equals(123.into_value()),
    Predicate::Never,
]);
assert_eq!(p.check(&v), true);

let p = Predicate::Or(vec![
    Predicate::Never,
    Predicate::Equals(123.into_value()),
]);
assert_eq!(p.check(&v), true);

let p = Predicate::Or(vec![
    Predicate::Never,
    Predicate::Never,
]);
assert_eq!(p.check(&v), false);
§

TextContainedIn(String)

Will be true if checked value is text that is a substring if the specified string (case sensitive)

§Examples
use entity::{Predicate, Value};
let v = Value::from("substring");

let p = Predicate::TextContainedIn(String::from("my substring of text"));
assert_eq!(p.check(&v), true);

let p = Predicate::TextContainedIn(String::from("my string of text"));
assert_eq!(p.check(&v), false);
§

TextContainedInCaseInsensitive(String)

Will be true if checked value is text that is a substring if the specified string (case insensitive)

§Examples
use entity::{Predicate, Value};
let v = Value::from("substring");

let p = Predicate::TextContainedInCaseInsensitive(String::from("MY SUBSTRING OF TEXT"));
assert_eq!(p.check(&v), true);

let p = Predicate::TextContainedInCaseInsensitive(String::from("my string of text"));
assert_eq!(p.check(&v), false);
§

TextContainsAll(Vec<String>)

Will be true if checked value is text that contains all of the specified strings as substrings (case sensitive)

§Examples
use entity::{Predicate, Value};
let v = Value::from("my text that is compared");

let p = Predicate::TextContainsAll(vec![
    String::from("my"),
    String::from("text"),
    String::from("compared"),
]);
assert_eq!(p.check(&v), true);

let p = Predicate::TextContainsAll(vec![
    String::from("my"),
    String::from("other"),
    String::from("compared"),
]);
assert_eq!(p.check(&v), false);
§

TextContainsAllCaseInsensitive(Vec<String>)

Will be true if checked value is text that contains all of the specified strings as substrings (case insensitive)

§Examples
use entity::{Predicate, Value};
let v = Value::from("my text that is compared");

let p = Predicate::TextContainsAllCaseInsensitive(vec![
    String::from("MY"),
    String::from("TEXT"),
    String::from("COMPARED"),
]);
assert_eq!(p.check(&v), true);

let p = Predicate::TextContainsAllCaseInsensitive(vec![
    String::from("my"),
    String::from("other"),
    String::from("compared"),
]);
assert_eq!(p.check(&v), false);
§

TextContainsAny(Vec<String>)

Will be true if checked value is text that contains any of the specified strings as substrings (case sensitive)

§Examples
use entity::{Predicate, Value};
let v = Value::from("my text that is compared");

let p = Predicate::TextContainsAny(vec![
    String::from("something"),
    String::from("text"),
    String::from("other"),
]);
assert_eq!(p.check(&v), true);

let p = Predicate::TextContainsAny(vec![
    String::from("something"),
    String::from("not"),
    String::from("other"),
]);
assert_eq!(p.check(&v), false);
§

TextContainsAnyCaseInsensitive(Vec<String>)

Will be true if checked value is text that contains any of the specified strings as substrings (case insensitive)

§Examples
use entity::{Predicate, Value};
let v = Value::from("my text that is compared");

let p = Predicate::TextContainsAnyCaseInsensitive(vec![
    String::from("SOMETHING"),
    String::from("TEXT"),
    String::from("OTHER"),
]);
assert_eq!(p.check(&v), true);

let p = Predicate::TextContainsAnyCaseInsensitive(vec![
    String::from("something"),
    String::from("not"),
    String::from("other"),
]);
assert_eq!(p.check(&v), false);
§

TextEndsWith(String)

Will be true if checked value is text that ends with the specified string (case sensitive)

§Examples
use entity::{Predicate, Value};
let v = Value::from("some text");

let p = Predicate::TextEndsWith(String::from("text"));
assert_eq!(p.check(&v), true);

let p = Predicate::TextEndsWith(String::from("TEXT"));
assert_eq!(p.check(&v), false);
§

TextEndsWithCaseInsensitive(String)

Will be true if checked value is text that ends with the specified string (case insensitive)

§Examples
use entity::{Predicate, Value};
let v = Value::from("some text");

let p = Predicate::TextEndsWithCaseInsensitive(String::from("TEXT"));
assert_eq!(p.check(&v), true);

let p = Predicate::TextEndsWithCaseInsensitive(String::from("some"));
assert_eq!(p.check(&v), false);
§

TextEndsWithAny(Vec<String>)

Will be true if checked value is text that ends with any of the specified strings (case sensitive)

§Examples
use entity::{Predicate, Value};
let v = Value::from("my text that is compared");

let p = Predicate::TextEndsWithAny(vec![
    String::from("something"),
    String::from("compared"),
    String::from("other"),
]);
assert_eq!(p.check(&v), true);

let p = Predicate::TextEndsWithAny(vec![
    String::from("something"),
    String::from("COMPARED"),
    String::from("other"),
]);
assert_eq!(p.check(&v), false);
§

TextEndsWithAnyCaseInsensitive(Vec<String>)

Will be true if checked value is text that ends with any of the specified strings (case insensitive)

§Examples
use entity::{Predicate, Value};
let v = Value::from("my text that is compared");

let p = Predicate::TextEndsWithAnyCaseInsensitive(vec![
    String::from("SOMETHING"),
    String::from("COMPARED"),
    String::from("OTHER"),
]);
assert_eq!(p.check(&v), true);

let p = Predicate::TextEndsWithAnyCaseInsensitive(vec![
    String::from("something"),
    String::from("text"),
    String::from("other"),
]);
assert_eq!(p.check(&v), false);
§

TextEqualsCaseInsensitive(String)

Will be true if checked value is text that equals the specified string (case insensitive)

§Examples
use entity::{Predicate, Value};
let v = Value::from("some text");

let p = Predicate::TextEqualsCaseInsensitive(String::from("SOME TEXT"));
assert_eq!(p.check(&v), true);

let p = Predicate::TextEqualsCaseInsensitive(String::from("other text"));
assert_eq!(p.check(&v), false);
§

TextNotEqualsCaseInsensitive(String)

Will be true if checked value is text that does not equal the specified string (case insensitive); or if any other type than text

§Examples
use entity::{Predicate, Value};
let v = Value::from("some text");

let p = Predicate::TextNotEqualsCaseInsensitive(String::from("other text"));
assert_eq!(p.check(&v), true);

let p = Predicate::TextNotEqualsCaseInsensitive(String::from("SOME TEXT"));
assert_eq!(p.check(&v), false);
§

TextInSetCaseInsensitive(HashSet<String>)

Will be true if checked value is text that is found within the specified set of strings

§Examples
use entity::{Predicate, Value};
let v = Value::from("some text");

let p = Predicate::TextInSetCaseInsensitive(vec![
    String::from("SOME"),
    String::from("SOME TEXT"),
    String::from("TEXT"),
].into_iter().collect());
assert_eq!(p.check(&v), true);

let p = Predicate::TextInSetCaseInsensitive(vec![
    String::from("OTHER"),
    String::from("OTHER TEXT"),
    String::from("TEXT"),
].into_iter().collect());
assert_eq!(p.check(&v), false);
§

TextStartsWith(String)

Will be true if checked value is text that starts with the specified string (case sensitive)

§Examples
use entity::{Predicate, Value};
let v = Value::from("some text");

let p = Predicate::TextStartsWith(String::from("some"));
assert_eq!(p.check(&v), true);

let p = Predicate::TextStartsWith(String::from("SOME"));
assert_eq!(p.check(&v), false);
§

TextStartsWithCaseInsensitive(String)

Will be true if checked value is text that starts with the specified string (case insensitive)

§Examples
use entity::{Predicate, Value};
let v = Value::from("some text");

let p = Predicate::TextStartsWithCaseInsensitive(String::from("SOME"));
assert_eq!(p.check(&v), true);

let p = Predicate::TextStartsWithCaseInsensitive(String::from("text"));
assert_eq!(p.check(&v), false);
§

TextStartsWithAny(Vec<String>)

Will be true if checked value is text that starts with any of the specified strings as substrings (case sensitive)

§Examples
use entity::{Predicate, Value};
let v = Value::from("my text that is compared");

let p = Predicate::TextStartsWithAny(vec![
    String::from("something"),
    String::from("my"),
    String::from("other"),
]);
assert_eq!(p.check(&v), true);

let p = Predicate::TextStartsWithAny(vec![
    String::from("something"),
    String::from("MY"),
    String::from("other"),
]);
assert_eq!(p.check(&v), false);
§

TextStartsWithAnyCaseInsensitive(Vec<String>)

Will be true if checked value is text that starts with any of the specified strings as substrings (case insensitive)

§Examples
use entity::{Predicate, Value};
let v = Value::from("my text that is compared");

let p = Predicate::TextStartsWithAnyCaseInsensitive(vec![
    String::from("SOMETHING"),
    String::from("MY"),
    String::from("OTHER"),
]);
assert_eq!(p.check(&v), true);

let p = Predicate::TextStartsWithAnyCaseInsensitive(vec![
    String::from("something"),
    String::from("not"),
    String::from("other"),
]);
assert_eq!(p.check(&v), false);
§

Xor(Vec<Predicate>)

Will be true if only one predicate returns true against the checked value

§Examples
use entity::{Predicate, Value, ValueLike};
let v = 123.into_value();

let p = Predicate::Xor(vec![
    Predicate::Never,
    Predicate::Equals(123.into_value()),
]);
assert_eq!(p.check(&v), true);

let p = Predicate::Xor(vec![
    Predicate::Equals(123.into_value()),
    Predicate::Never,
]);
assert_eq!(p.check(&v), true);

let p = Predicate::Xor(vec![
    Predicate::GreaterThan(122.into_value()),
    Predicate::LessThan(124.into_value()),
]);
assert_eq!(p.check(&v), false);

let p = Predicate::Xor(vec![
    Predicate::Never,
    Predicate::Never,
]);
assert_eq!(p.check(&v), false);

Implementations§

Source§

impl Predicate

Source

pub fn check(&self, value: &Value) -> bool

Checks if the predicate is satisfied by the given value

Source

pub fn always() -> Self

Creates a new predicate for Predicate::Always

§Examples
use entity::{Predicate as P, Value as V};

let p = P::always();
assert_eq!(p.check(&V::from(1)), true);
Source

pub fn never() -> Self

Creates a new predicate for Predicate::Never

§Examples
use entity::{Predicate as P, Value as V};

let p = P::never();
assert_eq!(p.check(&V::from(1)), false);
Source

pub fn lambda<F: 'static + Fn(&Value) -> bool>(f: F) -> Self

Creates a new predicate for Predicate::Lambda

§Examples
use entity::{Predicate as P, Value as V};

let p = P::lambda(|v| v > &V::from(3));
assert_eq!(p.check(&V::from(4)), true);
assert_eq!(p.check(&V::from(1)), false);
Source

pub fn and<P: Into<Predicate>, I: IntoIterator<Item = P>>(i: I) -> Self

Creates a new predicate for Predicate::And

§Examples
use entity::{Predicate as P, Value as V};

let p = P::and(vec![
    P::greater_than(1),
    P::less_than(3),
]);
assert_eq!(p.check(&V::from(2)), true);
assert_eq!(p.check(&V::from(1)), false);
Source

pub fn not<P: Into<Predicate>>(p: P) -> Self

Creates a new predicate for Predicate::Not

§Examples
use entity::{Predicate as P, Value as V};

let p = P::not(P::greater_than(1));
assert_eq!(p.check(&V::from(1)), true);
assert_eq!(p.check(&V::from(2)), false);
Source

pub fn or<P: Into<Predicate>, I: IntoIterator<Item = P>>(i: I) -> Self

Creates a new predicate for Predicate::Or

§Examples
use entity::{Predicate as P, Value as V};

let p = P::or(vec![P::greater_than(1), P::equals(1)]);
assert_eq!(p.check(&V::from(1)), true);
assert_eq!(p.check(&V::from(2)), true);
assert_eq!(p.check(&V::from(0)), false);
Source

pub fn xor<P: Into<Predicate>, I: IntoIterator<Item = P>>(i: I) -> Self

Creates a new predicate for Predicate::Xor

§Examples
use entity::{Predicate as P, Value as V};

let p = P::xor(vec![P::greater_than(1), P::greater_than(2)]);
assert_eq!(p.check(&V::from(2)), true);
assert_eq!(p.check(&V::from(3)), false);
assert_eq!(p.check(&V::from(1)), false);
Source

pub fn any<P: Into<Predicate>>(p: P) -> Self

Creates a new predicate for Predicate::Any

§Examples
use entity::{Predicate as P, Value as V};

let p = P::any(P::equals(3));
assert_eq!(p.check(&V::from(vec![1, 2, 3])), true);

let p = P::any(P::equals(4));
assert_eq!(p.check(&V::from(vec![1, 2, 3])), false);
Source

pub fn contains<T: ValueLike>(value: T) -> Self

Creates a new predicate for Predicate::Contains

§Examples
use entity::{Predicate as P, Value as V};

let p = P::contains(3);
assert_eq!(p.check(&V::from(vec![1, 2, 3])), true);

let p = P::contains(4);
assert_eq!(p.check(&V::from(vec![1, 2, 3])), false);
Source

pub fn contains_all<T: ValueLike, I: IntoIterator<Item = T>>(i: I) -> Self

Creates a new predicate for Predicate::ContainsAll

§Examples
use entity::{Predicate as P, Value as V};

let p = P::contains_all(vec![1, 3]);
assert_eq!(p.check(&V::from(vec![1, 2, 3])), true);

let p = P::contains_all(vec![1, 4]);
assert_eq!(p.check(&V::from(vec![1, 2, 3])), false);
Source

pub fn contains_any<T: ValueLike, I: IntoIterator<Item = T>>(i: I) -> Self

Creates a new predicate for Predicate::ContainsAny

§Examples
use entity::{Predicate as P, Value as V};

let p = P::contains_any(vec![1, 4]);
assert_eq!(p.check(&V::from(vec![1, 2, 3])), true);

let p = P::contains_any(vec![4, 5]);
assert_eq!(p.check(&V::from(vec![1, 2, 3])), false);
Source

pub fn equals<T: ValueLike>(value: T) -> Self

Creates a new predicate for Predicate::Equals

§Examples
use entity::{Predicate as P, Value as V};

let p = P::equals(3);
assert_eq!(p.check(&V::from(3)), true);
assert_eq!(p.check(&V::from(2)), false);
Source

pub fn greater_than<T: ValueLike>(value: T) -> Self

Creates a new predicate for Predicate::GreaterThan

§Examples
use entity::{Predicate as P, Value as V};

let p = P::greater_than(3);
assert_eq!(p.check(&V::from(4)), true);
assert_eq!(p.check(&V::from(3)), false);
Source

pub fn greater_than_or_equals<T: ValueLike>(value: T) -> Self

Creates a new predicate for Predicate::GreaterThanOrEquals

§Examples
use entity::{Predicate as P, Value as V};

let p = P::greater_than_or_equals(3);
assert_eq!(p.check(&V::from(4)), true);
assert_eq!(p.check(&V::from(3)), true);
assert_eq!(p.check(&V::from(2)), false);
Source

pub fn in_range<T: ValueLike>(range: RangeInclusive<T>) -> Self

Creates a new predicate for Predicate::InRange

§Examples
use entity::{Predicate as P, Value as V};

let p = P::in_range(3..=5);
assert_eq!(p.check(&V::from(2)), false);
assert_eq!(p.check(&V::from(3)), true);
assert_eq!(p.check(&V::from(4)), true);
assert_eq!(p.check(&V::from(5)), true);
assert_eq!(p.check(&V::from(6)), false);
Source

pub fn in_set<T: ValueLike, I: IntoIterator<Item = T>>(set: I) -> Self

Creates a new predicate for Predicate::InSet

§Examples
use entity::{Predicate as P, Value as V};

let p = P::in_set(vec![1, 2, 3]);
assert_eq!(p.check(&V::from(0)), false);
assert_eq!(p.check(&V::from(1)), true);
assert_eq!(p.check(&V::from(2)), true);
assert_eq!(p.check(&V::from(3)), true);
assert_eq!(p.check(&V::from(4)), false);
Source

pub fn less_than<T: ValueLike>(value: T) -> Self

Creates a new predicate for Predicate::LessThan

§Examples
use entity::{Predicate as P, Value as V};

let p = P::less_than(3);
assert_eq!(p.check(&V::from(2)), true);
assert_eq!(p.check(&V::from(3)), false);
Source

pub fn less_than_or_equals<T: ValueLike>(value: T) -> Self

Creates a new predicate for Predicate::LessThanOrEquals

§Examples
use entity::{Predicate as P, Value as V};

let p = P::less_than_or_equals(3);
assert_eq!(p.check(&V::from(2)), true);
assert_eq!(p.check(&V::from(3)), true);
assert_eq!(p.check(&V::from(4)), false);
Source

pub fn not_equals<T: ValueLike>(value: T) -> Self

Creates a new predicate for Predicate::NotEquals

use entity::{Predicate as P, Value as V};

let p = P::not_equals(3);
assert_eq!(p.check(&V::from(2)), true);
assert_eq!(p.check(&V::from(3)), false);
Source

pub fn not_in_range<T: ValueLike>(range: RangeInclusive<T>) -> Self

Creates a new predicate for Predicate::NotInRange

§Examples
use entity::{Predicate as P, Value as V};

let p = P::not_in_range(3..=5);
assert_eq!(p.check(&V::from(2)), true);
assert_eq!(p.check(&V::from(3)), false);
assert_eq!(p.check(&V::from(4)), false);
assert_eq!(p.check(&V::from(5)), false);
assert_eq!(p.check(&V::from(6)), true);
Source

pub fn not_in_set<T: ValueLike, I: IntoIterator<Item = T>>(set: I) -> Self

Creates a new predicate for Predicate::NotInSet

§Examples
use entity::{Predicate as P, Value as V};

let p = P::not_in_set(vec![1, 2, 3]);
assert_eq!(p.check(&V::from(0)), true);
assert_eq!(p.check(&V::from(1)), false);
assert_eq!(p.check(&V::from(2)), false);
assert_eq!(p.check(&V::from(3)), false);
assert_eq!(p.check(&V::from(4)), true);
Source

pub fn has_key<K: Into<String>>(k: K) -> Self

Creates a new predicate for Predicate::HasKey

§Examples
use entity::{Predicate as P, Value as V};
use std::collections::HashMap;

let map: HashMap<String, u32> = vec![
    (String::from("a"), 1),
    (String::from("b"), 2),
    (String::from("c"), 3),
].into_iter().collect();

let p = P::has_key("a");
assert_eq!(p.check(&V::from(map.clone())), true);

let p = P::has_key("d");
assert_eq!(p.check(&V::from(map)), false);
Source

pub fn has_key_where_value<K: Into<String>, P: Into<Predicate>>( k: K, p: P, ) -> Self

Creates a new typed predicate for Predicate::HasKeyWhereValue

§Examples
use entity::{Predicate as P, Value as V};
use std::collections::HashMap;

let map: HashMap<String, u32> = vec![
    (String::from("a"), 1),
    (String::from("b"), 2),
    (String::from("c"), 3),
].into_iter().collect();

let p = P::has_key_where_value("a", P::equals(1));
assert_eq!(p.check(&V::from(map.clone())), true);

let p = P::has_key_where_value("b", P::equals(1));
assert_eq!(p.check(&V::from(map.clone())), false);

let p = P::has_key_where_value("d", P::equals(1));
assert_eq!(p.check(&V::from(map)), false);
Source

pub fn is_none() -> Self

Creates a new predicate for Predicate::IsNone

§Examples
use entity::{Predicate as P, Value as V};

let p = P::is_none();
assert_eq!(p.check(&V::from(None::<u32>)), true);
assert_eq!(p.check(&V::from(Some(3))), false);
Source

pub fn not_none_and<P: Into<Predicate>>(p: P) -> Self

Creates a new predicate for Predicate::NotNoneAnd

§Examples
use entity::{Predicate as P, Value as V};

let p = P::not_none_and(P::equals(3));
assert_eq!(p.check(&V::from(Some(3))), true);
assert_eq!(p.check(&V::from(Some(2))), false);
assert_eq!(p.check(&V::from(None::<u32>)), false);
Source

pub fn none_or<P: Into<Predicate>>(p: P) -> Self

Creates a new predicate for Predicate::NoneOr

§Examples
use entity::{Predicate as P, Value as V};

let p = P::none_or(P::equals(3));
assert_eq!(p.check(&V::from(Some(3))), true);
assert_eq!(p.check(&V::from(None::<u32>)), true);
assert_eq!(p.check(&V::from(Some(2))), false);
Source

pub fn text_ends_with<S: Into<String>>(s: S) -> Self

Creates a new predicate for Predicate::TextEndsWith

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_ends_with("text");

assert_eq!(p.check(&V::from("some text")), true);
assert_eq!(p.check(&V::from("text some")), false);
Source

pub fn text_ends_with_case_insensitive<S: Into<String>>(s: S) -> Self

Creates a new predicate for Predicate::TextEndsWithCaseInsensitive

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_ends_with_case_insensitive("text");

assert_eq!(p.check(&V::from("SOME TEXT")), true);
assert_eq!(p.check(&V::from("TEXT SOME")), false);
Source

pub fn text_equals_case_insensitive<S: Into<String>>(s: S) -> Self

Creates a new predicate for Predicate::TextEqualsCaseInsensitive

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_equals_case_insensitive("text");

assert_eq!(p.check(&V::from("TEXT")), true);
assert_eq!(p.check(&V::from("OTHER")), false);
Source

pub fn text_in_set_case_insensitive<S: Into<String>, I: IntoIterator<Item = S>>( i: I, ) -> Self

Creates a new predicate for Predicate::TextInSetCaseInsensitive

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_in_set_case_insensitive(vec!["one", "two", "three"]);

assert_eq!(p.check(&V::from("TWO")), true);
assert_eq!(p.check(&V::from("FOUR")), false);
Source

pub fn text_not_equals_case_insensitive<S: Into<String>>(s: S) -> Self

Creates a new predicate for Predicate::TextNotEqualsCaseInsensitive

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_not_equals_case_insensitive("text");

assert_eq!(p.check(&V::from("OTHER")), true);
assert_eq!(p.check(&V::from("TEXT")), false);
Source

pub fn text_starts_with<S: Into<String>>(s: S) -> Self

Creates a new predicate for Predicate::TextStartsWith

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_starts_with("text");

assert_eq!(p.check(&V::from("text some")), true);
assert_eq!(p.check(&V::from("some text")), false);
Source

pub fn text_starts_with_case_insensitive<S: Into<String>>(s: S) -> Self

Creates a new predicate for Predicate::TextStartsWithCaseInsensitive

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_starts_with_case_insensitive("text");

assert_eq!(p.check(&V::from("TEXT SOME")), true);
assert_eq!(p.check(&V::from("SOME TEXT")), false);
Source

pub fn text_contained_in<S: Into<String>>(s: S) -> Self

Creates a new predicate for Predicate::TextContainedIn

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_contained_in("text");

assert_eq!(p.check(&V::from("ex")), true);
assert_eq!(p.check(&V::from("tt")), false);
Source

pub fn text_contained_in_case_insensitive<S: Into<String>>(s: S) -> Self

Creates a new predicate for Predicate::TextContainedInCaseInsensitive

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_contained_in_case_insensitive("text");

assert_eq!(p.check(&V::from("EX")), true);
assert_eq!(p.check(&V::from("TT")), false);
Source

pub fn text_contains_all<S: Into<String>, I: IntoIterator<Item = S>>( i: I, ) -> Self

Creates a new predicate for Predicate::TextContainsAll

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_contains_all(vec!["one", "two", "three"]);

assert_eq!(p.check(&V::from("my one and two and three text")), true);
assert_eq!(p.check(&V::from("my one and two text")), false);
Source

pub fn text_contains_all_case_insensitive<S: Into<String>, I: IntoIterator<Item = S>>( i: I, ) -> Self

Creates a new predicate for Predicate::TextContainsAllCaseInsensitive

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_contains_all_case_insensitive(vec!["one", "two", "three"]);

assert_eq!(p.check(&V::from("MY ONE AND TWO AND THREE TEXT")), true);
assert_eq!(p.check(&V::from("MY ONE AND TWO TEXT")), false);
Source

pub fn text_contains_any<S: Into<String>, I: IntoIterator<Item = S>>( i: I, ) -> Self

Creates a new predicate for Predicate::TextContainsAny

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_contains_any(vec!["one", "two", "three"]);

assert_eq!(p.check(&V::from("my one text")), true);
assert_eq!(p.check(&V::from("my four text")), false);
Source

pub fn text_contains_any_case_insensitive<S: Into<String>, I: IntoIterator<Item = S>>( i: I, ) -> Self

Creates a new predicate for Predicate::TextContainsAnyCaseInsensitive

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_contains_any_case_insensitive(vec!["one", "two", "three"]);

assert_eq!(p.check(&V::from("MY ONE TEXT")), true);
assert_eq!(p.check(&V::from("MY FOUR TEXT")), false);
Source

pub fn text_ends_with_any<S: Into<String>, I: IntoIterator<Item = S>>( i: I, ) -> Self

Creates a new predicate for Predicate::TextEndsWithAny

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_ends_with_any(vec!["one", "two", "three"]);

assert_eq!(p.check(&V::from("my text one")), true);
assert_eq!(p.check(&V::from("one my text")), false);
Source

pub fn text_ends_with_any_case_insensitive<S: Into<String>, I: IntoIterator<Item = S>>( i: I, ) -> Self

Creates a new predicate for Predicate::TextEndsWithAnyCaseInsensitive

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_ends_with_any_case_insensitive(vec!["one", "two", "three"]);

assert_eq!(p.check(&V::from("MY TEXT ONE")), true);
assert_eq!(p.check(&V::from("ONE MY TEXT")), false);
Source

pub fn text_starts_with_any<S: Into<String>, I: IntoIterator<Item = S>>( i: I, ) -> Self

Creates a new predicate for Predicate::TextStartsWithAny

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_starts_with_any(vec!["one", "two", "three"]);

assert_eq!(p.check(&V::from("one my text")), true);
assert_eq!(p.check(&V::from("my text one")), false);
Source

pub fn text_starts_with_any_case_insensitive<S: Into<String>, I: IntoIterator<Item = S>>( i: I, ) -> Self

Creates a new predicate for Predicate::TextStartsWithAnyCaseInsensitive

§Examples
use entity::{Predicate as P, Value as V};

let p = P::text_starts_with_any_case_insensitive(vec!["one", "two", "three"]);

assert_eq!(p.check(&V::from("ONE MY TEXT")), true);
assert_eq!(p.check(&V::from("MY TEXT ONE")), false);

Trait Implementations§

Source§

impl BitAnd for Predicate

Source§

fn bitand(self, rhs: Self) -> Self

Shorthand to produce Predicate::And

§Examples
use entity::{Predicate, Value, ValueLike};

assert_eq!(
    Predicate::Equals(123.into_value()) & Predicate::Equals(124.into_value()),
    Predicate::And(vec![
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
);

If the left-hand side is already a Predicate::And, the returned predicate will be an updated instance:

use entity::{Predicate, Value, ValueLike};

assert_eq!(
    Predicate::And(vec![
        Predicate::Equals(122.into_value()),
        Predicate::Equals(123.into_value()),
    ]) & Predicate::Equals(124.into_value()),
    Predicate::And(vec![
        Predicate::Equals(122.into_value()),
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
);

If the right-hand side is already a Predicate::And, the returned predicate will be an updated instance:

use entity::{Predicate, Value, ValueLike};

assert_eq!(
    Predicate::Equals(122.into_value()) & Predicate::And(vec![
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
    Predicate::And(vec![
        Predicate::Equals(122.into_value()),
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
);

If both sides are already a Predicate::And, the returned predicate will be a merge:

use entity::{Predicate, Value, ValueLike};

assert_eq!(
    Predicate::And(vec![
        Predicate::Equals(121.into_value()),
        Predicate::Equals(122.into_value()),
    ]) & Predicate::And(vec![
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
    Predicate::And(vec![
        Predicate::Equals(121.into_value()),
        Predicate::Equals(122.into_value()),
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
);
Source§

type Output = Predicate

The resulting type after applying the & operator.
Source§

impl BitOr for Predicate

Source§

fn bitor(self, rhs: Self) -> Self

Shorthand to produce Predicate::Or

§Examples
use entity::{Predicate, Value, ValueLike};

assert_eq!(
    Predicate::Equals(123.into_value()) | Predicate::Equals(124.into_value()),
    Predicate::Or(vec![
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
);

If the left-hand side is already a Predicate::Or, the returned predicate will be an updated instance:

use entity::{Predicate, Value, ValueLike};

assert_eq!(
    Predicate::Or(vec![
        Predicate::Equals(122.into_value()),
        Predicate::Equals(123.into_value()),
    ]) | Predicate::Equals(124.into_value()),
    Predicate::Or(vec![
        Predicate::Equals(122.into_value()),
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
);

If the right-hand side is already a Predicate::Or, the returned predicate will be an updated instance:

use entity::{Predicate, Value, ValueLike};

assert_eq!(
    Predicate::Equals(122.into_value()) | Predicate::Or(vec![
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
    Predicate::Or(vec![
        Predicate::Equals(122.into_value()),
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
);

If both sides are already a Predicate::Or, the returned predicate will be a merge:

use entity::{Predicate, Value, ValueLike};

assert_eq!(
    Predicate::Or(vec![
        Predicate::Equals(121.into_value()),
        Predicate::Equals(122.into_value()),
    ]) | Predicate::Or(vec![
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
    Predicate::Or(vec![
        Predicate::Equals(121.into_value()),
        Predicate::Equals(122.into_value()),
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
);
Source§

type Output = Predicate

The resulting type after applying the | operator.
Source§

impl BitXor for Predicate

Source§

fn bitxor(self, rhs: Self) -> Self

Shorthand to produce Predicate::Xor

§Examples
use entity::{Predicate, Value, ValueLike};

assert_eq!(
    Predicate::Equals(123.into_value()) ^ Predicate::Equals(124.into_value()),
    Predicate::Xor(vec![
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
);

If the left-hand side is already a Predicate::Xor, the returned predicate will be an updated instance:

use entity::{Predicate, Value, ValueLike};

assert_eq!(
    Predicate::Xor(vec![
        Predicate::Equals(122.into_value()),
        Predicate::Equals(123.into_value()),
    ]) ^ Predicate::Equals(124.into_value()),
    Predicate::Xor(vec![
        Predicate::Equals(122.into_value()),
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
);

If the right-hand side is already a Predicate::Xor, the returned predicate will be an updated instance:

use entity::{Predicate, Value, ValueLike};

assert_eq!(
    Predicate::Equals(122.into_value()) ^ Predicate::Xor(vec![
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
    Predicate::Xor(vec![
        Predicate::Equals(122.into_value()),
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
);

If both sides are already a Predicate::Xor, the returned predicate will be a merge:

use entity::{Predicate, Value, ValueLike};

assert_eq!(
    Predicate::Xor(vec![
        Predicate::Equals(121.into_value()),
        Predicate::Equals(122.into_value()),
    ]) ^ Predicate::Xor(vec![
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
    Predicate::Xor(vec![
        Predicate::Equals(121.into_value()),
        Predicate::Equals(122.into_value()),
        Predicate::Equals(123.into_value()),
        Predicate::Equals(124.into_value()),
    ]),
);
Source§

type Output = Predicate

The resulting type after applying the ^ operator.
Source§

impl Clone for Predicate

Source§

fn clone(&self) -> Predicate

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Predicate

Source§

fn fmt(&self, __f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> From<MapTypedPredicate<T, C>> for Predicate

Source§

fn from(map_typed_predicate: MapTypedPredicate<T, C>) -> Self

Converts to this type from the input type.
Source§

impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> From<Predicate> for MapTypedPredicate<T, C>

Source§

fn from(predicate: Predicate) -> Self

Converts to this type from the input type.
Source§

impl<T: ValueLike> From<Predicate> for TypedPredicate<T>

Source§

fn from(predicate: Predicate) -> Self

Converts to this type from the input type.
Source§

impl<T: ValueLike> From<TypedPredicate<T>> for Predicate

Source§

fn from(typed_predicate: TypedPredicate<T>) -> Self

Converts to this type from the input type.
Source§

impl Not for Predicate

Source§

fn not(self) -> Self::Output

Shorthand to produce Predicate::Not

§Examples
use entity::{Predicate, Value, ValueLike};

assert_eq!(
    !Predicate::Equals(123.into_value()),
    Predicate::Not(Box::new(Predicate::Equals(123.into_value()))),
);
Source§

type Output = Predicate

The resulting type after applying the ! operator.
Source§

impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> PartialEq<Predicate> for MapTypedPredicate<T, C>

Source§

fn eq(&self, other: &Predicate) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: ValueLike> PartialEq<Predicate> for TypedPredicate<T>

Source§

fn eq(&self, other: &Predicate) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: ValueLike> PartialEq<TypedPredicate<T>> for Predicate

Source§

fn eq(&self, other: &TypedPredicate<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Predicate

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts reference to Any
Source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

converts mutable reference to Any
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.