pub struct Expectation { /* private fields */ }
👎Deprecated since 0.9.0: Using automock directly on an extern block is deprecated. Instead, wrap the extern block in a module, and automock that, like #[automock] mod ffi { extern “C” { fn foo … } }
Expand description

Expectation type for methods that return a 'static type. This is the type returned by the expect_* methods.

Implementations

👎Deprecated since 0.9.0: Using automock directly on an extern block is deprecated. Instead, wrap the extern block in a module, and automock that, like #[automock] mod ffi { extern “C” { fn foo … } }

Return a constant value from the Expectation

The output type must be Clone. The compiler can’t always infer the proper type to use with this method; you will usually need to specify it explicitly. i.e. return_const(42i32) instead of return_const(42).

👎Deprecated since 0.9.0: Using automock directly on an extern block is deprecated. Instead, wrap the extern block in a module, and automock that, like #[automock] mod ffi { extern “C” { fn foo … } }

Single-threaded version of return_const. This is useful for return types that are not Send.

The output type must be Clone. The compiler can’t always infer the proper type to use with this method; you will usually need to specify it explicitly. i.e. return_const(42i32) instead of return_const(42).

It is a runtime error to call the mock method from a different thread than the one that originally called this method.

👎Deprecated since 0.9.0: Using automock directly on an extern block is deprecated. Instead, wrap the extern block in a module, and automock that, like #[automock] mod ffi { extern “C” { fn foo … } }

Supply an FnOnce closure that will provide the return value for this Expectation. This is useful for return types that aren’t Clone. It will be an error to call this method multiple times.

👎Deprecated since 0.9.0: Using automock directly on an extern block is deprecated. Instead, wrap the extern block in a module, and automock that, like #[automock] mod ffi { extern “C” { fn foo … } }

Single-threaded version of return_once. This is useful for return types that are neither Send nor Clone.

It is a runtime error to call the mock method from a different thread than the one that originally called this method. It is also a runtime error to call the method more than once.

👎Deprecated since 0.9.0: Using automock directly on an extern block is deprecated. Instead, wrap the extern block in a module, and automock that, like #[automock] mod ffi { extern “C” { fn foo … } }

Supply a closure that will provide the return value for this Expectation. The method’s arguments are passed to the closure by value.

👎Deprecated since 0.9.0: Using automock directly on an extern block is deprecated. Instead, wrap the extern block in a module, and automock that, like #[automock] mod ffi { extern “C” { fn foo … } }

Single-threaded version of returning. Can be used when the argument or return type isn’t Send.

It is a runtime error to call the mock method from a different thread than the one that originally called this method.

👎Deprecated since 0.9.0: Using automock directly on an extern block is deprecated. Instead, wrap the extern block in a module, and automock that, like #[automock] mod ffi { extern “C” { fn foo … } }

Add this expectation to a Sequence.

👎Deprecated since 0.9.0: Using automock directly on an extern block is deprecated. Instead, wrap the extern block in a module, and automock that, like #[automock] mod ffi { extern “C” { fn foo … } }

Forbid this expectation from ever being called.

👎Deprecated since 0.9.0: Using automock directly on an extern block is deprecated. Instead, wrap the extern block in a module, and automock that, like #[automock] mod ffi { extern “C” { fn foo … } }

Create a new, default, Expectation

👎Deprecated since 0.9.0: Using automock directly on an extern block is deprecated. Instead, wrap the extern block in a module, and automock that, like #[automock] mod ffi { extern “C” { fn foo … } }

Expect this expectation to be called exactly once. Shortcut for times(1).

👎Deprecated since 0.9.0: Using automock directly on an extern block is deprecated. Instead, wrap the extern block in a module, and automock that, like #[automock] mod ffi { extern “C” { fn foo … } }

Restrict the number of times that that this method may be called.

The argument may be:

  • A fixed number: .times(4)
  • Various types of range:
    • .times(5..10)
    • .times(..10)
    • .times(5..)
    • .times(5..=10)
    • .times(..=10)
  • The wildcard: .times(..)
👎Deprecated since 0.9.0: Using automock directly on an extern block is deprecated. Instead, wrap the extern block in a module, and automock that, like #[automock] mod ffi { extern “C” { fn foo … } }

Set matching crieteria for this Expectation.

The matching predicate can be anything implemening the Predicate trait. Only one matcher can be set per Expectation at a time.

👎Deprecated since 0.9.0: Using automock directly on an extern block is deprecated. Instead, wrap the extern block in a module, and automock that, like #[automock] mod ffi { extern “C” { fn foo … } }

Set a matching function for this Expectation.

This is equivalent to calling with with a function argument, like with(predicate::function(f)).

👎Deprecated since 0.9.0: Using automock directly on an extern block is deprecated. Instead, wrap the extern block in a module, and automock that, like #[automock] mod ffi { extern “C” { fn foo … } }

Single-threaded version of withf. Can be used when the argument type isn’t Send.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.