Struct entity::query::TypedPredicate [−][src]
pub struct TypedPredicate<T: ValueLike>(_, _);
Represents a typed Predicate
, ensuring that only valid conditions are
used for a given type
Implementations
impl<T: ValueLike> TypedPredicate<T>
[src]
pub fn lambda<F: 'static + Fn(T) -> bool>(f: F) -> Self
[src]
Creates a new typed predicate for Predicate::Lambda
Examples
use entity::TypedPredicate as P; let p = P::lambda(|x| x > 3); assert_eq!(p.check(4), true); assert_eq!(p.check(1), false);
impl<T: ValueLike> TypedPredicate<T>
[src]
pub fn new(predicate: Predicate) -> Self
[src]
Creates a new typed predicate from an untyped predicate
pub fn as_untyped(&self) -> &Predicate
[src]
Returns a reference to the untyped Predicate
wrapped by this
typed instance
pub fn check(&self, value: T) -> bool
[src]
Checks if the typed predicate is satisfied by the given value
NOTE: This consumes the value instead of the untyped version that merely references the value
pub fn always() -> Self
[src]
Creates a new typed predicate for Predicate::Always
Examples
use entity::TypedPredicate as P; let p = P::always(); assert_eq!(p.check(1), true);
pub fn never() -> Self
[src]
Creates a new typed predicate for Predicate::Never
Examples
use entity::TypedPredicate as P; let p = P::never(); assert_eq!(p.check(1), false);
pub fn and<P: Into<TypedPredicate<T>>, I: IntoIterator<Item = P>>(i: I) -> Self
[src]
Creates a new typed predicate for Predicate::And
Examples
use entity::TypedPredicate as P; let p = P::and(vec![ P::greater_than(1), P::less_than(3), ]); assert_eq!(p.check(2), true); assert_eq!(p.check(1), false);
pub fn not<P: Into<TypedPredicate<T>>>(p: P) -> Self
[src]
Creates a new typed predicate for Predicate::Not
Examples
use entity::TypedPredicate as P; let p = P::not(P::greater_than(1)); assert_eq!(p.check(1), true); assert_eq!(p.check(2), false);
pub fn or<P: Into<TypedPredicate<T>>, I: IntoIterator<Item = P>>(i: I) -> Self
[src]
Creates a new typed predicate for Predicate::Or
Examples
use entity::TypedPredicate as P; let p = P::or(vec![P::greater_than(1), P::equals(1)]); assert_eq!(p.check(1), true); assert_eq!(p.check(2), true); assert_eq!(p.check(0), false);
pub fn xor<P: Into<TypedPredicate<T>>, I: IntoIterator<Item = P>>(i: I) -> Self
[src]
Creates a new typed predicate for Predicate::Xor
Examples
use entity::TypedPredicate as P; let p = P::xor(vec![P::greater_than(1), P::greater_than(2)]); assert_eq!(p.check(2), true); assert_eq!(p.check(3), false); assert_eq!(p.check(1), false);
impl<T: ValueLike, C: IntoIterator<Item = T> + ValueLike> TypedPredicate<C>
[src]
Implementation for collections with a singular type. For
std::collections::HashMap
and similar types, use the
MapTypedPredicate
instead.
pub fn any<P: Into<TypedPredicate<T>>>(p: P) -> Self
[src]
Creates a new typed predicate for Predicate::Any
Examples
use entity::TypedPredicate as P; let p = P::any(P::equals(3)); assert_eq!(p.check(vec![1, 2, 3]), true); let p = P::any(P::equals(4)); assert_eq!(p.check(vec![1, 2, 3]), false);
pub fn contains(value: T) -> Self
[src]
Creates a new typed predicate for Predicate::Contains
Examples
use entity::TypedPredicate as P; let p = P::contains(3); assert_eq!(p.check(vec![1, 2, 3]), true); let p = P::contains(4); assert_eq!(p.check(vec![1, 2, 3]), false);
pub fn contains_all<I: IntoIterator<Item = T>>(i: I) -> Self
[src]
Creates a new typed predicate for Predicate::ContainsAll
Examples
use entity::TypedPredicate as P; let p = P::contains_all(vec![1, 3]); assert_eq!(p.check(vec![1, 2, 3]), true); let p = P::contains_all(vec![1, 4]); assert_eq!(p.check(vec![1, 2, 3]), false);
pub fn contains_any<I: IntoIterator<Item = T>>(i: I) -> Self
[src]
Creates a new typed predicate for Predicate::ContainsAny
Examples
use entity::TypedPredicate as P; let p = P::contains_any(vec![1, 4]); assert_eq!(p.check(vec![1, 2, 3]), true); let p = P::contains_any(vec![4, 5]); assert_eq!(p.check(vec![1, 2, 3]), false);
impl<T: ValueLike> TypedPredicate<T>
[src]
pub fn equals(value: T) -> Self
[src]
Creates a new typed predicate for Predicate::Equals
Examples
use entity::TypedPredicate as P; let p = P::equals(3); assert_eq!(p.check(3), true); assert_eq!(p.check(2), false);
pub fn greater_than(value: T) -> Self
[src]
Creates a new typed predicate for Predicate::GreaterThan
Examples
use entity::TypedPredicate as P; let p = P::greater_than(3); assert_eq!(p.check(4), true); assert_eq!(p.check(3), false);
pub fn greater_than_or_equals(value: T) -> Self
[src]
Creates a new typed predicate for Predicate::GreaterThanOrEquals
Examples
use entity::TypedPredicate as P; let p = P::greater_than_or_equals(3); assert_eq!(p.check(4), true); assert_eq!(p.check(3), true); assert_eq!(p.check(2), false);
pub fn in_range(range: RangeInclusive<T>) -> Self
[src]
Creates a new typed predicate for Predicate::InRange
Examples
use entity::TypedPredicate as P; let p = P::in_range(3..=5); assert_eq!(p.check(2), false); assert_eq!(p.check(3), true); assert_eq!(p.check(4), true); assert_eq!(p.check(5), true); assert_eq!(p.check(6), false);
pub fn in_set<I: IntoIterator<Item = T>>(set: I) -> Self
[src]
Creates a new typed predicate for Predicate::InSet
Examples
use entity::TypedPredicate as P; let p = P::in_set(vec![1, 2, 3]); assert_eq!(p.check(0), false); assert_eq!(p.check(1), true); assert_eq!(p.check(2), true); assert_eq!(p.check(3), true); assert_eq!(p.check(4), false);
pub fn less_than(value: T) -> Self
[src]
Creates a new typed predicate for Predicate::LessThan
Examples
use entity::TypedPredicate as P; let p = P::less_than(3); assert_eq!(p.check(2), true); assert_eq!(p.check(3), false);
pub fn less_than_or_equals(value: T) -> Self
[src]
Creates a new typed predicate for Predicate::LessThanOrEquals
Examples
use entity::TypedPredicate as P; let p = P::less_than_or_equals(3); assert_eq!(p.check(2), true); assert_eq!(p.check(3), true); assert_eq!(p.check(4), false);
pub fn not_equals(value: T) -> Self
[src]
Creates a new typed predicate for Predicate::NotEquals
use entity::TypedPredicate as P; let p = P::not_equals(3); assert_eq!(p.check(2), true); assert_eq!(p.check(3), false);
pub fn not_in_range(range: RangeInclusive<T>) -> Self
[src]
Creates a new typed predicate for Predicate::NotInRange
Examples
use entity::TypedPredicate as P; let p = P::not_in_range(3..=5); assert_eq!(p.check(2), true); assert_eq!(p.check(3), false); assert_eq!(p.check(4), false); assert_eq!(p.check(5), false); assert_eq!(p.check(6), true);
pub fn not_in_set<I: IntoIterator<Item = T>>(set: I) -> Self
[src]
Creates a new typed predicate for Predicate::NotInSet
Examples
use entity::TypedPredicate as P; let p = P::not_in_set(vec![1, 2, 3]); assert_eq!(p.check(0), true); assert_eq!(p.check(1), false); assert_eq!(p.check(2), false); assert_eq!(p.check(3), false); assert_eq!(p.check(4), true);
impl<T: ValueLike> TypedPredicate<HashMap<String, T>>
[src]
pub fn has_key<K: Into<String>>(k: K) -> Self
[src]
Creates a new typed predicate for Predicate::HasKey
Examples
use entity::TypedPredicate as P; 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(map.clone()), true); let p = P::has_key("d"); assert_eq!(p.check(map), false);
pub fn has_key_where_value<K: Into<String>, P: Into<TypedPredicate<T>>>(
k: K,
p: P
) -> Self
[src]
k: K,
p: P
) -> Self
Creates a new typed predicate for Predicate::HasKeyWhereValue
Examples
use entity::TypedPredicate as P; 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(map.clone()), true); let p = P::has_key_where_value("b", P::equals(1)); assert_eq!(p.check(map.clone()), false); let p = P::has_key_where_value("d", P::equals(1)); assert_eq!(p.check(map), false);
impl<T: ValueLike> TypedPredicate<Option<T>>
[src]
pub fn is_none() -> Self
[src]
Creates a new typed predicate for Predicate::IsNone
Examples
use entity::TypedPredicate as P; let p = P::is_none(); let v = None::<u32>; assert_eq!(p.check(v), true); let v = Some(3); assert_eq!(p.check(v), false);
pub fn not_none_and<P: Into<TypedPredicate<T>>>(p: P) -> Self
[src]
Creates a new typed predicate for Predicate::NotNoneAnd
Examples
use entity::TypedPredicate as P; let p = P::not_none_and(P::equals(3)); let v = Some(3); assert_eq!(p.check(v), true); let v = Some(2); assert_eq!(p.check(v), false); let v = None::<u32>; assert_eq!(p.check(v), false);
pub fn none_or<P: Into<TypedPredicate<T>>>(p: P) -> Self
[src]
Creates a new typed predicate for Predicate::NoneOr
Examples
use entity::TypedPredicate as P; let p = P::none_or(P::equals(3)); let v = Some(3); assert_eq!(p.check(v), true); let v = None::<u32>; assert_eq!(p.check(v), true); let v = Some(2); assert_eq!(p.check(v), false);
impl TypedPredicate<String>
[src]
pub fn text_ends_with<S: Into<String>>(s: S) -> Self
[src]
Creates a new typed predicate for Predicate::TextEndsWith
Examples
use entity::TypedPredicate as P; let p = P::text_ends_with("text"); assert_eq!(p.check(String::from("some text")), true); assert_eq!(p.check(String::from("text some")), false);
pub fn text_ends_with_case_insensitive<S: Into<String>>(s: S) -> Self
[src]
Creates a new typed predicate for Predicate::TextEndsWithCaseInsensitive
Examples
use entity::TypedPredicate as P; let p = P::text_ends_with_case_insensitive("text"); assert_eq!(p.check(String::from("SOME TEXT")), true); assert_eq!(p.check(String::from("TEXT SOME")), false);
pub fn text_equals_case_insensitive<S: Into<String>>(s: S) -> Self
[src]
Creates a new typed predicate for Predicate::TextEqualsCaseInsensitive
Examples
use entity::TypedPredicate as P; let p = P::text_equals_case_insensitive("text"); assert_eq!(p.check(String::from("TEXT")), true); assert_eq!(p.check(String::from("OTHER")), false);
pub fn text_in_set_case_insensitive<S: Into<String>, I: IntoIterator<Item = S>>(
i: I
) -> Self
[src]
i: I
) -> Self
Creates a new typed predicate for Predicate::TextInSetCaseInsensitive
Examples
use entity::TypedPredicate as P; let p = P::text_in_set_case_insensitive(vec!["one", "two", "three"]); assert_eq!(p.check(String::from("TWO")), true); assert_eq!(p.check(String::from("FOUR")), false);
pub fn text_not_equals_case_insensitive<S: Into<String>>(s: S) -> Self
[src]
Creates a new typed predicate for Predicate::TextNotEqualsCaseInsensitive
Examples
use entity::TypedPredicate as P; let p = P::text_not_equals_case_insensitive("text"); assert_eq!(p.check(String::from("OTHER")), true); assert_eq!(p.check(String::from("TEXT")), false);
pub fn text_starts_with<S: Into<String>>(s: S) -> Self
[src]
Creates a new typed predicate for Predicate::TextStartsWith
Examples
use entity::TypedPredicate as P; let p = P::text_starts_with("text"); assert_eq!(p.check(String::from("text some")), true); assert_eq!(p.check(String::from("some text")), false);
pub fn text_starts_with_case_insensitive<S: Into<String>>(s: S) -> Self
[src]
Creates a new typed predicate for Predicate::TextStartsWithCaseInsensitive
Examples
use entity::TypedPredicate as P; let p = P::text_starts_with_case_insensitive("text"); assert_eq!(p.check(String::from("TEXT SOME")), true); assert_eq!(p.check(String::from("SOME TEXT")), false);
pub fn text_contained_in<S: Into<String>>(s: S) -> Self
[src]
Creates a new typed predicate for Predicate::TextContainedIn
Examples
use entity::TypedPredicate as P; let p = P::text_contained_in("text"); assert_eq!(p.check(String::from("ex")), true); assert_eq!(p.check(String::from("tt")), false);
pub fn text_contained_in_case_insensitive<S: Into<String>>(s: S) -> Self
[src]
Creates a new typed predicate for Predicate::TextContainedInCaseInsensitive
Examples
use entity::TypedPredicate as P; let p = P::text_contained_in_case_insensitive("text"); assert_eq!(p.check(String::from("EX")), true); assert_eq!(p.check(String::from("TT")), false);
pub fn text_contains_all<S: Into<String>, I: IntoIterator<Item = S>>(
i: I
) -> Self
[src]
i: I
) -> Self
Creates a new typed predicate for Predicate::TextContainsAll
Examples
use entity::TypedPredicate as P; let p = P::text_contains_all(vec!["one", "two", "three"]); assert_eq!(p.check(String::from("my one and two and three text")), true); assert_eq!(p.check(String::from("my one and two text")), false);
pub fn text_contains_all_case_insensitive<S: Into<String>, I: IntoIterator<Item = S>>(
i: I
) -> Self
[src]
i: I
) -> Self
Creates a new typed predicate for Predicate::TextContainsAllCaseInsensitive
Examples
use entity::TypedPredicate as P; let p = P::text_contains_all_case_insensitive(vec!["one", "two", "three"]); assert_eq!(p.check(String::from("MY ONE AND TWO AND THREE TEXT")), true); assert_eq!(p.check(String::from("MY ONE AND TWO TEXT")), false);
pub fn text_contains_any<S: Into<String>, I: IntoIterator<Item = S>>(
i: I
) -> Self
[src]
i: I
) -> Self
Creates a new typed predicate for Predicate::TextContainsAny
Examples
use entity::TypedPredicate as P; let p = P::text_contains_any(vec!["one", "two", "three"]); assert_eq!(p.check(String::from("my one text")), true); assert_eq!(p.check(String::from("my four text")), false);
pub fn text_contains_any_case_insensitive<S: Into<String>, I: IntoIterator<Item = S>>(
i: I
) -> Self
[src]
i: I
) -> Self
Creates a new typed predicate for Predicate::TextContainsAnyCaseInsensitive
Examples
use entity::TypedPredicate as P; let p = P::text_contains_any_case_insensitive(vec!["one", "two", "three"]); assert_eq!(p.check(String::from("MY ONE TEXT")), true); assert_eq!(p.check(String::from("MY FOUR TEXT")), false);
pub fn text_ends_with_any<S: Into<String>, I: IntoIterator<Item = S>>(
i: I
) -> Self
[src]
i: I
) -> Self
Creates a new typed predicate for Predicate::TextEndsWithAny
Examples
use entity::TypedPredicate as P; let p = P::text_ends_with_any(vec!["one", "two", "three"]); assert_eq!(p.check(String::from("my text one")), true); assert_eq!(p.check(String::from("one my text")), false);
pub fn text_ends_with_any_case_insensitive<S: Into<String>, I: IntoIterator<Item = S>>(
i: I
) -> Self
[src]
i: I
) -> Self
Creates a new typed predicate for Predicate::TextEndsWithAnyCaseInsensitive
Examples
use entity::TypedPredicate as P; let p = P::text_ends_with_any_case_insensitive(vec!["one", "two", "three"]); assert_eq!(p.check(String::from("MY TEXT ONE")), true); assert_eq!(p.check(String::from("ONE MY TEXT")), false);
pub fn text_starts_with_any<S: Into<String>, I: IntoIterator<Item = S>>(
i: I
) -> Self
[src]
i: I
) -> Self
Creates a new typed predicate for Predicate::TextStartsWithAny
Examples
use entity::TypedPredicate as P; let p = P::text_starts_with_any(vec!["one", "two", "three"]); assert_eq!(p.check(String::from("one my text")), true); assert_eq!(p.check(String::from("my text one")), false);
pub fn text_starts_with_any_case_insensitive<S: Into<String>, I: IntoIterator<Item = S>>(
i: I
) -> Self
[src]
i: I
) -> Self
Creates a new typed predicate for Predicate::TextStartsWithAnyCaseInsensitive
Examples
use entity::TypedPredicate as P; let p = P::text_starts_with_any_case_insensitive(vec!["one", "two", "three"]); assert_eq!(p.check(String::from("ONE MY TEXT")), true); assert_eq!(p.check(String::from("MY TEXT ONE")), false);
Trait Implementations
impl<T: ValueLike> BitAnd<TypedPredicate<T>> for TypedPredicate<T>
[src]
type Output = Self
The resulting type after applying the &
operator.
fn bitand(self, rhs: Self) -> Self
[src]
Shorthand to produce Predicate::And
impl<T: ValueLike> BitOr<TypedPredicate<T>> for TypedPredicate<T>
[src]
type Output = Self
The resulting type after applying the |
operator.
fn bitor(self, rhs: Self) -> Self
[src]
Shorthand to produce Predicate::Or
impl<T: ValueLike> BitXor<TypedPredicate<T>> for TypedPredicate<T>
[src]
type Output = Self
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: Self) -> Self
[src]
Shorthand to produce Predicate::Xor
impl<T: Clone + ValueLike> Clone for TypedPredicate<T>
[src]
fn clone(&self) -> TypedPredicate<T>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Debug + ValueLike> Debug for TypedPredicate<T>
[src]
impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> From<MapTypedPredicate<T, C>> for TypedPredicate<C>
[src]
fn from(map_typed_predicate: MapTypedPredicate<T, C>) -> Self
[src]
impl<T: ValueLike> From<Predicate> for TypedPredicate<T>
[src]
impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> From<TypedPredicate<C>> for MapTypedPredicate<T, C>
[src]
fn from(typed_predicate: TypedPredicate<C>) -> Self
[src]
impl<T: ValueLike> From<TypedPredicate<T>> for Predicate
[src]
fn from(typed_predicate: TypedPredicate<T>) -> Self
[src]
impl<T: ValueLike> Not for TypedPredicate<T>
[src]
type Output = Self
The resulting type after applying the !
operator.
fn not(self) -> Self::Output
[src]
Shorthand to produce Predicate::Not
impl<T: ValueLike> PartialEq<Predicate> for TypedPredicate<T>
[src]
fn eq(&self, other: &Predicate) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T: ValueLike> PartialEq<TypedPredicate<T>> for Predicate
[src]
fn eq(&self, other: &TypedPredicate<T>) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T: PartialEq + ValueLike> PartialEq<TypedPredicate<T>> for TypedPredicate<T>
[src]
fn eq(&self, other: &TypedPredicate<T>) -> bool
[src]
fn ne(&self, other: &TypedPredicate<T>) -> bool
[src]
impl<T: ValueLike> StructuralPartialEq for TypedPredicate<T>
[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for TypedPredicate<T>
impl<T> !Send for TypedPredicate<T>
impl<T> !Sync for TypedPredicate<T>
impl<T> Unpin for TypedPredicate<T> where
T: Unpin,
T: Unpin,
impl<T> !UnwindSafe for TypedPredicate<T>
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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
pub fn __clone_box(&self, Private) -> *mut ()
[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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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.
pub 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>,