Enum pact_models::bodies::OptionalBody [−][src]
pub enum OptionalBody { Missing, Empty, Null, Present(Bytes, Option<ContentType>), }
Enum that defines the four main states that a body of a request and response can be in a pact file.
Variants
A body is missing if it is not present in the pact file
An empty body that is present in the pact file.
A JSON body that is the null value. This state is to protect other language implementations
from null values. It is treated as Empty
.
Present(Bytes, Option<ContentType>)
A non-empty body that is present in the pact file.
Implementations
impl OptionalBody
[src]
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 Clone for OptionalBody
[src]fn clone(&self) -> OptionalBody
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'de> Deserialize<'de> for OptionalBody
[src]
impl<'de> Deserialize<'de> for OptionalBody
[src]fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Eq for OptionalBody
[src]
impl Eq for OptionalBody
[src]impl Hash for OptionalBody
[src]
impl Hash for OptionalBody
[src]impl PartialEq<OptionalBody> for OptionalBody
[src]
impl PartialEq<OptionalBody> for OptionalBody
[src]fn eq(&self, other: &OptionalBody) -> bool
[src]
fn ne(&self, other: &OptionalBody) -> bool
[src]
impl Serialize for OptionalBody
[src]
impl Serialize for OptionalBody
[src]impl StructuralEq for OptionalBody
[src]
impl StructuralEq for OptionalBody
[src]impl StructuralPartialEq for OptionalBody
[src]
impl StructuralPartialEq for OptionalBody
[src]Auto Trait Implementations
impl RefUnwindSafe for OptionalBody
impl RefUnwindSafe for OptionalBody
impl Send for OptionalBody
impl Send for OptionalBody
impl Sync for OptionalBody
impl Sync for OptionalBody
impl Unpin for OptionalBody
impl Unpin for OptionalBody
impl UnwindSafe for OptionalBody
impl UnwindSafe for OptionalBody