Struct mockers::CallMatch3

source ·
pub struct CallMatch3<Arg0, Arg1, Arg2, Res> { /* private fields */ }
Expand description

$call_match (e.g. CallMatch1) struct allows to check whether mock method call matches given criteria.

Implementations§

source§

impl<Arg0, Arg1, Arg2, Res> CallMatch3<Arg0, Arg1, Arg2, Res>

source

pub fn new( mock_id: usize, mock_type_id: usize, method_name: &'static str, type_param_ids: Vec<usize>, arg0: Box<dyn MatchArg<Arg0>>, arg1: Box<dyn MatchArg<Arg1>>, arg2: Box<dyn MatchArg<Arg2>> ) -> Self

source§

impl<Arg0: 'static, Arg1: 'static, Arg2: 'static, Res: 'static> CallMatch3<Arg0, Arg1, Arg2, Res>

source

pub fn and_return( self, result: Res ) -> SendWrapper<Expectation3<Arg0, Arg1, Arg2, Res, impl FnOnce(Arg0, Arg1, Arg2) -> Res>>

Returns expectation with ignores all arguments and returns given value.

Since Res is not Clone it can only be returned once, thus expectation is returned, not reaction. If result is Clone, you may use $call_match::and_return_clone.

source

pub fn and_panic( self, msg: String ) -> SendWrapper<Expectation3<Arg0, Arg1, Arg2, Res, impl FnOnce(Arg0, Arg1, Arg2) -> Res>>

Returns expectation with ignores all arguments and panics with given message.

Since panic aborts execution, expectation is returned instead of reaction. However, std::panic::catch_unwind can be used, so this decision may be reconsidered.

source

pub fn and_call<F>( self, func: F ) -> SendWrapper<Expectation3<Arg0, Arg1, Arg2, Res, impl FnOnce(Arg0, Arg1, Arg2) -> Res>>
where F: FnOnce(Arg0, Arg1, Arg2) -> Res + 'static,

Returns expectation which passes all arguments to given closure and returns closure result.

Since closure is FnOnce, only one call is possible, thus expectation is returned, not reaction.

source

pub fn never(self) -> SendWrapper<ExpectationNever<Self>>

Returns expectation which ensures that matching call is never executed.

source§

impl<Arg0, Arg1, Arg2, Res: Clone + 'static> CallMatch3<Arg0, Arg1, Arg2, Res>

source

pub fn and_return_clone(self, result: Res) -> Reaction3<Arg0, Arg1, Arg2, Res>

Returns reaction which returns clone of given value.

source§

impl<Arg0, Arg1, Arg2, Res> CallMatch3<Arg0, Arg1, Arg2, Res>

source

pub fn and_call_clone<F>(self, func: F) -> Reaction3<Arg0, Arg1, Arg2, Res>
where F: FnMut(Arg0, Arg1, Arg2) -> Res + 'static,

Returns reaction which passed method arguments to given closure and returns closure result.

source§

impl<Arg0, Arg1, Arg2, Res: Default + 'static> CallMatch3<Arg0, Arg1, Arg2, Res>

source

pub fn and_return_default(self) -> Reaction3<Arg0, Arg1, Arg2, Res>

Returns reaction which returns default value of result type.

Trait Implementations§

source§

impl<Arg0, Arg1, Arg2, Res> CallMatch for CallMatch3<Arg0, Arg1, Arg2, Res>

source§

fn matches_args(&self, call: &Call) -> bool

source§

fn validate(&self, call: &Call) -> Vec<Result<(), String>>

source§

fn get_mock_id(&self) -> usize

source§

fn get_mock_type_id(&self) -> usize

source§

fn get_method_name(&self) -> &'static str

source§

fn get_type_param_ids(&self) -> &[usize]

source§

fn describe(&self) -> String

source§

fn matches(&self, call: &Call) -> bool

source§

fn matches_target(&self, call: &Call) -> bool

source§

fn matches_generic_method(&self, call: &Call) -> bool

source§

fn matches_method(&self, call: &Call) -> bool

Auto Trait Implementations§

§

impl<Arg0, Arg1, Arg2, Res> !RefUnwindSafe for CallMatch3<Arg0, Arg1, Arg2, Res>

§

impl<Arg0, Arg1, Arg2, Res> !Send for CallMatch3<Arg0, Arg1, Arg2, Res>

§

impl<Arg0, Arg1, Arg2, Res> !Sync for CallMatch3<Arg0, Arg1, Arg2, Res>

§

impl<Arg0, Arg1, Arg2, Res> Unpin for CallMatch3<Arg0, Arg1, Arg2, Res>
where Res: Unpin,

§

impl<Arg0, Arg1, Arg2, Res> !UnwindSafe for CallMatch3<Arg0, Arg1, Arg2, Res>

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>,

§

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>,

§

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.