Enum mockito::Matcher

source ·
pub enum Matcher {
    Exact(String),
    Binary(BinaryBody),
    Regex(String),
    Json(Value),
    JsonString(String),
    PartialJson(Value),
    PartialJsonString(String),
    UrlEncoded(StringString),
    AnyOf(Vec<Matcher>),
    AllOf(Vec<Matcher>),
    Any,
    Missing,
}
Expand description

Allows matching the request path or headers in multiple ways: matching the exact value, matching any value (as long as it is present), matching by regular expression or checking that a particular header is missing.

These matchers are used within the mock and Mock::match_header calls.

Variants§

§

Exact(String)

Matches the exact path or header value. There’s also an implementation of From<&str> to keep things simple and backwards compatible.

§

Binary(BinaryBody)

Matches the body content as a binary file

§

Regex(String)

Matches a path or header value by a regular expression.

§

Json(Value)

Matches a specified JSON body from a serde_json::Value

§

JsonString(String)

Matches a specified JSON body from a String

§

PartialJson(Value)

Matches a partial JSON body from a serde_json::Value

§

PartialJsonString(String)

Matches a specified partial JSON body from a String

§

UrlEncoded(StringString)

Matches a URL-encoded key/value pair, where both key and value should be specified in plain (unencoded) format

§

AnyOf(Vec<Matcher>)

At least one matcher must match

§

AllOf(Vec<Matcher>)

All matchers must match

§

Any

Matches any path or any header value.

§

Missing

Checks that a header is not present in the request.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. 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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
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.