mockall

Trait Predicate

Source
pub trait Predicate<Item>: PredicateReflection
where Item: ?Sized,
{ // Required method fn eval(&self, variable: &Item) -> bool; // Provided method fn find_case<'a>( &'a self, expected: bool, variable: &Item, ) -> Option<Case<'a>> { ... } }
Expand description

Trait for generically evaluating a type against a dynamically created predicate function.

The exact meaning of eval depends on the situation, but will usually mean that the evaluated item is in some sort of pre-defined set. This is different from Ord and Eq in that an item will almost never be the same type as the implementing Predicate type.

Required Methods§

Source

fn eval(&self, variable: &Item) -> bool

Execute this Predicate against variable, returning the resulting boolean.

Provided Methods§

Source

fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<Case<'a>>

Find a case that proves this predicate as expected when run against variable.

Implementations on Foreign Types§

Source§

impl Predicate<str> for StrFilePredicate

Source§

fn eval(&self, actual: &str) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

Source§

impl Predicate<str> for ContainsPredicate

Source§

fn eval(&self, variable: &str) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

Source§

impl Predicate<str> for EndsWithPredicate

Source§

fn eval(&self, variable: &str) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

Source§

impl Predicate<str> for IsEmptyPredicate

Source§

fn eval(&self, variable: &str) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

Source§

impl Predicate<str> for MatchesPredicate

Source§

fn eval(&self, variable: &str) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

Source§

impl Predicate<str> for StartsWithPredicate

Source§

fn eval(&self, variable: &str) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

Source§

impl Predicate<Path> for ExistencePredicate

Source§

fn eval(&self, path: &Path) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &Path) -> Option<Case<'a>>

Source§

impl Predicate<Path> for BinaryFilePredicate

Source§

fn eval(&self, path: &Path) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &Path) -> Option<Case<'a>>

Source§

impl Predicate<Path> for StrFilePredicate

Source§

fn eval(&self, path: &Path) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &Path) -> Option<Case<'a>>

Source§

impl Predicate<Path> for FileTypePredicate

Source§

fn eval(&self, path: &Path) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &Path) -> Option<Case<'a>>

Source§

impl Predicate<[u8]> for BinaryFilePredicate

Source§

fn eval(&self, actual: &[u8]) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &[u8]) -> Option<Case<'a>>

Source§

impl<F, T> Predicate<T> for FnPredicate<F, T>
where F: Fn(&T) -> bool, T: ?Sized,

Source§

fn eval(&self, variable: &T) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &T) -> Option<Case<'a>>

Source§

impl<Item> Predicate<Item> for BoxPredicate<Item>
where Item: ?Sized,

Source§

fn eval(&self, variable: &Item) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<Case<'a>>

Source§

impl<Item> Predicate<Item> for BooleanPredicate
where Item: ?Sized,

Source§

fn eval(&self, _variable: &Item) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<Case<'a>>

Source§

impl<M1, M2, Item> Predicate<Item> for AndPredicate<M1, M2, Item>
where M1: Predicate<Item>, M2: Predicate<Item>, Item: ?Sized,

Source§

fn eval(&self, item: &Item) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<Case<'a>>

Source§

impl<M1, M2, Item> Predicate<Item> for OrPredicate<M1, M2, Item>
where M1: Predicate<Item>, M2: Predicate<Item>, Item: ?Sized,

Source§

fn eval(&self, item: &Item) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<Case<'a>>

Source§

impl<M, Item> Predicate<Item> for NotPredicate<M, Item>
where M: Predicate<Item>, Item: ?Sized,

Source§

fn eval(&self, item: &Item) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<Case<'a>>

Source§

impl<M, Item> Predicate<Item> for NamePredicate<M, Item>
where M: Predicate<Item>, Item: ?Sized,

Source§

fn eval(&self, item: &Item) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<Case<'a>>

Source§

impl<P> Predicate<str> for TrimPredicate<P>
where P: Predicate<str>,

Source§

fn eval(&self, variable: &str) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

Source§

impl<P> Predicate<OsStr> for Utf8Predicate<P>
where P: Predicate<str>,

Source§

fn eval(&self, variable: &OsStr) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &OsStr) -> Option<Case<'a>>

Source§

impl<P> Predicate<Path> for FileContentPredicate<P>
where P: Predicate<[u8]>,

Source§

fn eval(&self, path: &Path) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &Path) -> Option<Case<'a>>

Source§

impl<P> Predicate<[u8]> for Utf8Predicate<P>
where P: Predicate<str>,

Source§

fn eval(&self, variable: &[u8]) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &[u8]) -> Option<Case<'a>>

Source§

impl<P, T> Predicate<P> for HashableInPredicate<T>
where T: Borrow<P> + Hash + Eq + Debug, P: Hash + Eq + Debug + ?Sized,

Source§

fn eval(&self, variable: &P) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &P) -> Option<Case<'a>>

Source§

impl<P, T> Predicate<P> for InPredicate<T>
where T: Borrow<P> + PartialEq + Debug, P: PartialEq + Debug + ?Sized,

Source§

fn eval(&self, variable: &P) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &P) -> Option<Case<'a>>

Source§

impl<P, T> Predicate<P> for OrdInPredicate<T>
where T: Borrow<P> + Ord + Debug, P: Ord + Debug + ?Sized,

Source§

fn eval(&self, variable: &P) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &P) -> Option<Case<'a>>

Source§

impl<P, T> Predicate<P> for EqPredicate<T>
where T: Borrow<P> + Debug, P: Debug + PartialEq + ?Sized,

Source§

fn eval(&self, variable: &P) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &P) -> Option<Case<'a>>

Source§

impl<P, T> Predicate<P> for OrdPredicate<T>
where T: Borrow<P> + Debug, P: Debug + PartialOrd + ?Sized,

Source§

fn eval(&self, variable: &P) -> bool

Source§

fn find_case<'a>(&'a self, expected: bool, variable: &P) -> Option<Case<'a>>

Implementors§