Struct mockers::CallMatch0

source ·
pub struct CallMatch0<Res> { /* private fields */ }
Expand description

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

Implementations§

source§

impl<Res> CallMatch0<Res>

source

pub fn new( mock_id: usize, mock_type_id: usize, method_name: &'static str, type_param_ids: Vec<usize> ) -> Self

source§

impl<Res: 'static> CallMatch0<Res>

source

pub fn and_return( self, result: Res ) -> SendWrapper<Expectation0<Res, impl FnOnce() -> 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<Expectation0<Res, impl FnOnce() -> 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<Expectation0<Res, impl FnOnce() -> Res>>
where F: FnOnce() -> 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<Res: Clone + 'static> CallMatch0<Res>

source

pub fn and_return_clone(self, result: Res) -> Reaction0<Res>

Returns reaction which returns clone of given value.

source§

impl<Res> CallMatch0<Res>

source

pub fn and_call_clone<F>(self, func: F) -> Reaction0<Res>
where F: FnMut() -> Res + 'static,

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

source§

impl<Res: Default + 'static> CallMatch0<Res>

source

pub fn and_return_default(self) -> Reaction0<Res>

Returns reaction which returns default value of result type.

Trait Implementations§

source§

impl<Res> CallMatch for CallMatch0<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<Res> RefUnwindSafe for CallMatch0<Res>
where Res: RefUnwindSafe,

§

impl<Res> Send for CallMatch0<Res>
where Res: Send,

§

impl<Res> Sync for CallMatch0<Res>
where Res: Sync,

§

impl<Res> Unpin for CallMatch0<Res>
where Res: Unpin,

§

impl<Res> UnwindSafe for CallMatch0<Res>
where Res: 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>,

§

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.