Enum pact_matching::models::OptionalBody[][src]

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

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.

Implementations

impl OptionalBody[src]

pub fn is_present(&self) -> bool[src]

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

pub fn value(&self) -> Option<Bytes>[src]

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

pub fn str_value(&self) -> &str[src]

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

pub fn has_content_type(&self) -> bool[src]

If the body has a content type associated to it

pub fn content_type(&self) -> Option<ContentType>[src]

Parsed content type of the body

pub fn to_v4_json(&self) -> Value[src]

Converts this body into a V4 Pact file JSON format

Trait Implementations

impl Clone for OptionalBody[src]

impl Debug for OptionalBody[src]

impl<'de> Deserialize<'de> for OptionalBody[src]

impl Display for OptionalBody[src]

impl Eq for OptionalBody[src]

impl<'a> From<&'a str> for OptionalBody[src]

impl From<String> for OptionalBody[src]

impl Hash for OptionalBody[src]

impl PartialEq<OptionalBody> for OptionalBody[src]

impl Serialize for OptionalBody[src]

impl StructuralEq for OptionalBody[src]

impl StructuralPartialEq for OptionalBody[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,