Enum pact_models::bodies::OptionalBody[][src]

pub enum OptionalBody {
    Missing,
    Empty,
    Null,
    Present(BytesOption<ContentType>, Option<ContentTypeHint>),
}
Expand description

Enum that defines the four main states that a body of a request and response can be in a pact file.

Variants

Missing

A body is missing if it is not present in the pact file

Empty

An empty body that is present in the pact file.

Null

A JSON body that is the null value. This state is to protect other language implementations from null values. It is treated as Empty.

A non-empty body that is present in the pact file.

Tuple Fields of Present

0: Bytes1: Option<ContentType>2: Option<ContentTypeHint>

Implementations

If the body is present in the pact file and not empty or null.

Returns the body if present, otherwise returns the empty buffer.

Returns the body if present as a UTF-8 string, otherwise returns the empty string.

If the body has a content type associated to it

Parsed content type of the body

Converts this body into a V4 Pact file JSON format

Set the content type of the body. If the body is missing or empty, this is a no-op.

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

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

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. 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

Compare self to key and return true if they are equal.

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more