Struct unimock::build::DefineMultipleResponses
source · [−]Expand description
A matched call pattern, ready for defining multiple response, requiring return values to implement Clone.
Implementations
sourceimpl<'p, F, O> DefineMultipleResponses<'p, F, O>where
F: MockFn + 'static,
O: Ordering,
impl<'p, F, O> DefineMultipleResponses<'p, F, O>where
F: MockFn + 'static,
O: Ordering,
sourceimpl<'p, F, O> DefineMultipleResponses<'p, F, O>where
F: MockFn + 'static,
O: Ordering,
impl<'p, F, O> DefineMultipleResponses<'p, F, O>where
F: MockFn + 'static,
O: Ordering,
sourcepub fn returns_default(self) -> Quantify<'p, F, O>where
F::Output: Default,
pub fn returns_default(self) -> Quantify<'p, F, O>where
F::Output: Default,
Specify the output of the call pattern by calling Default::default()
.
sourcepub fn returns_ref<T>(self, value: T) -> Quantify<'p, F, O>where
T: Borrow<F::Output> + Sized + Send + Sync + 'static,
pub fn returns_ref<T>(self, value: T) -> Quantify<'p, F, O>where
T: Borrow<F::Output> + Sized + Send + Sync + 'static,
Specify the output of the call to be a borrow of the provided value.
This works well when the lifetime of the returned reference is the same as self
.
Using this for 'static
references will produce a runtime error. For static references, use DefineResponse::returns_static.
sourcepub fn returns_static(self, value: &'static F::Output) -> Quantify<'p, F, O>where
F::Output: Send + Sync + 'static,
pub fn returns_static(self, value: &'static F::Output) -> Quantify<'p, F, O>where
F::Output: Send + Sync + 'static,
Specify the output of the call to be a reference to static value.
This must be used when the returned reference in the mocked trait is 'static
.
sourcepub fn answers<A, R>(self, func: A) -> Quantify<'p, F, O>where
A: for<'i> Fn(<F as MockInputs<'i>>::Inputs) -> R + Send + Sync + 'static,
R: Into<F::Output>,
F::Output: Sized,
pub fn answers<A, R>(self, func: A) -> Quantify<'p, F, O>where
A: for<'i> Fn(<F as MockInputs<'i>>::Inputs) -> R + Send + Sync + 'static,
R: Into<F::Output>,
F::Output: Sized,
Specify the output of the call pattern by invoking the given closure that can then compute it based on input parameters.
sourcepub fn answers_leaked_ref<A, R>(self, func: A) -> Quantify<'p, F, O>where
A: for<'i> Fn(<F as MockInputs<'i>>::Inputs) -> R + Send + Sync + 'static,
R: Borrow<F::Output> + 'static,
F::Output: Sized,
pub fn answers_leaked_ref<A, R>(self, func: A) -> Quantify<'p, F, O>where
A: for<'i> Fn(<F as MockInputs<'i>>::Inputs) -> R + Send + Sync + 'static,
R: Borrow<F::Output> + 'static,
F::Output: Sized,
Specify the output of the call pattern to be a static reference to leaked memory.
The value may be based on the value of input parameters.
This version will produce a new memory leak for every invocation of the answer function.
This method should only be used when computing a reference based on input parameters is necessary, which should not be a common use case.
sourcepub fn panics(self, message: impl Into<String>) -> Quantify<'p, F, O>
pub fn panics(self, message: impl Into<String>) -> Quantify<'p, F, O>
Prevent this call pattern from succeeding by explicitly panicking with a custom message.
sourcepub fn unmocked(self) -> Quantify<'p, F, O>
pub fn unmocked(self) -> Quantify<'p, F, O>
Instruct this call pattern to invoke its corresponding unmocked
function.
For this to work, the mocked trait must be configured with an unmock_with=[..]
parameter.
If unimock doesn’t find a way to unmock the function, this will panic when the function is called.