Struct pact_models::message::Message
source · pub struct Message {
pub id: Option<String>,
pub description: String,
pub provider_states: Vec<ProviderState>,
pub contents: OptionalBody,
pub metadata: HashMap<String, Value>,
pub matching_rules: MatchingRules,
pub generators: Generators,
}
Expand description
Struct that defines a message.
Fields§
§id: Option<String>
Interaction ID. This will only be set if the Pact file was fetched from a Pact Broker
description: String
Description of this message interaction. This needs to be unique in the pact file.
provider_states: Vec<ProviderState>
Optional provider state for the interaction.
See <https://docs.pact.io/getting_started/provider_states>
for more info on provider states.
contents: OptionalBody
The contents of the message
metadata: HashMap<String, Value>
Metadata associated with this message.
matching_rules: MatchingRules
Matching rules
generators: Generators
Generators
Implementations§
source§impl Message
impl Message
sourcepub fn from_json(
index: usize,
json: &Value,
spec_version: &PactSpecification
) -> Result<Message>
pub fn from_json( index: usize, json: &Value, spec_version: &PactSpecification ) -> Result<Message>
Constructs a Message
from the Json
struct.
sourcepub fn to_json(&self, spec_version: &PactSpecification) -> Value
pub fn to_json(&self, spec_version: &PactSpecification) -> Value
Converts this interaction to a Value
struct.
note: spec version is preserved for compatibility with the RequestResponsePact interface
and for future use
sourcepub fn message_content_type(&self) -> Option<ContentType>
pub fn message_content_type(&self) -> Option<ContentType>
Returns the content type of the message by returning the content type associated with the body, or by looking it up in the message metadata
sourcepub fn as_message_content(&self) -> MessageContents
pub fn as_message_content(&self) -> MessageContents
Converts this message into a V4 message content
Trait Implementations§
source§impl HttpPart for Message
impl HttpPart for Message
source§fn headers(&self) -> &Option<HashMap<String, Vec<String>>>
fn headers(&self) -> &Option<HashMap<String, Vec<String>>>
source§fn headers_mut(&mut self) -> &mut HashMap<String, Vec<String>>
fn headers_mut(&mut self) -> &mut HashMap<String, Vec<String>>
source§fn body(&self) -> &OptionalBody
fn body(&self) -> &OptionalBody
source§fn body_mut(&mut self) -> &mut OptionalBody
fn body_mut(&mut self) -> &mut OptionalBody
source§fn matching_rules(&self) -> &MatchingRules
fn matching_rules(&self) -> &MatchingRules
source§fn matching_rules_mut(&mut self) -> &mut MatchingRules
fn matching_rules_mut(&mut self) -> &mut MatchingRules
source§fn generators(&self) -> &Generators
fn generators(&self) -> &Generators
source§fn generators_mut(&mut self) -> &mut Generators
fn generators_mut(&mut self) -> &mut Generators
source§fn lookup_content_type(&self) -> Option<String>
fn lookup_content_type(&self) -> Option<String>
source§fn detect_content_type(&self) -> Option<ContentType>
fn detect_content_type(&self) -> Option<ContentType>
source§fn content_type(&self) -> Option<ContentType>
fn content_type(&self) -> Option<ContentType>
Content-Type
header is present, the
value of that header will be returned. Otherwise, the body will be inspected.source§fn has_header(&self, header_name: &str) -> bool
fn has_header(&self, header_name: &str) -> bool
source§fn lookup_header_value(&self, header_name: &str) -> Option<String>
fn lookup_header_value(&self, header_name: &str) -> Option<String>
source§fn has_text_body(&self) -> bool
fn has_text_body(&self) -> bool
source§fn build_generators(
&self,
category: &GeneratorCategory
) -> HashMap<DocPath, Generator>
fn build_generators( &self, category: &GeneratorCategory ) -> HashMap<DocPath, Generator>
source§impl Interaction for Message
impl Interaction for Message
source§fn is_request_response(&self) -> bool
fn is_request_response(&self) -> bool
source§fn as_request_response(&self) -> Option<RequestResponseInteraction>
fn as_request_response(&self) -> Option<RequestResponseInteraction>
source§fn is_message(&self) -> bool
fn is_message(&self) -> bool
source§fn as_message(&self) -> Option<Message>
fn as_message(&self) -> Option<Message>
source§fn id(&self) -> Option<String>
fn id(&self) -> Option<String>
source§fn description(&self) -> String
fn description(&self) -> String
source§fn set_description(&mut self, description: &str)
fn set_description(&mut self, description: &str)
source§fn provider_states(&self) -> Vec<ProviderState>
fn provider_states(&self) -> Vec<ProviderState>
<https://docs.pact.io/getting_started/provider_states>
for more info on provider states.source§fn provider_states_mut(&mut self) -> &mut Vec<ProviderState>
fn provider_states_mut(&mut self) -> &mut Vec<ProviderState>
<https://docs.pact.io/getting_started/provider_states>
for more info on provider states.source§fn contents(&self) -> OptionalBody
fn contents(&self) -> OptionalBody
source§fn contents_for_verification(&self) -> OptionalBody
fn contents_for_verification(&self) -> OptionalBody
source§fn content_type(&self) -> Option<ContentType>
fn content_type(&self) -> Option<ContentType>
Content-Type
header or metadata value is present, the
value of that value will be returned. Otherwise, the contents will be inspected.source§fn as_v4(&self) -> Option<Box<dyn V4Interaction + Send + Sync + RefUnwindSafe>>
fn as_v4(&self) -> Option<Box<dyn V4Interaction + Send + Sync + RefUnwindSafe>>
source§fn as_v4_mut(&mut self) -> Option<&mut dyn V4Interaction>
fn as_v4_mut(&mut self) -> Option<&mut dyn V4Interaction>
as_v4
method can convert to V4 format (via cloning the data).source§fn as_v4_http(&self) -> Option<SynchronousHttp>
fn as_v4_http(&self) -> Option<SynchronousHttp>
source§fn as_v4_async_message(&self) -> Option<AsynchronousMessage>
fn as_v4_async_message(&self) -> Option<AsynchronousMessage>
source§fn as_v4_sync_message(&self) -> Option<SynchronousMessage>
fn as_v4_sync_message(&self) -> Option<SynchronousMessage>
source§fn as_v4_http_mut(&mut self) -> Option<&mut SynchronousHttp>
fn as_v4_http_mut(&mut self) -> Option<&mut SynchronousHttp>
source§fn as_v4_async_message_mut(&mut self) -> Option<&mut AsynchronousMessage>
fn as_v4_async_message_mut(&mut self) -> Option<&mut AsynchronousMessage>
source§fn as_v4_sync_message_mut(&mut self) -> Option<&mut SynchronousMessage>
fn as_v4_sync_message_mut(&mut self) -> Option<&mut SynchronousMessage>
source§fn boxed(&self) -> Box<dyn Interaction + Send + Sync + RefUnwindSafe>
fn boxed(&self) -> Box<dyn Interaction + Send + Sync + RefUnwindSafe>
source§fn arced(&self) -> Arc<dyn Interaction + Send + Sync + RefUnwindSafe>
fn arced(&self) -> Arc<dyn Interaction + Send + Sync + RefUnwindSafe>
source§fn thread_safe(
&self
) -> Arc<Mutex<dyn Interaction + Send + Sync + RefUnwindSafe>>
fn thread_safe( &self ) -> Arc<Mutex<dyn Interaction + Send + Sync + RefUnwindSafe>>
source§fn matching_rules(&self) -> Option<MatchingRules>
fn matching_rules(&self) -> Option<MatchingRules>
source§fn is_v4_http(&self) -> bool
fn is_v4_http(&self) -> bool
source§fn is_v4_async_message(&self) -> bool
fn is_v4_async_message(&self) -> bool
source§fn is_v4_sync_message(&self) -> bool
fn is_v4_sync_message(&self) -> bool
source§impl PartialEq for Message
impl PartialEq for Message
impl Eq for Message
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.