Struct pact_models::message_pact::MessagePact

source ·
pub struct MessagePact {
    pub consumer: Consumer,
    pub provider: Provider,
    pub messages: Vec<Message>,
    pub metadata: BTreeMap<String, BTreeMap<String, String>>,
    pub specification_version: PactSpecification,
}
Expand description

Struct that represents a pact between the consumer and provider of a service. It contains a list of Messages instead of Interactions, but is otherwise identical to struct Pact.

Fields§

§consumer: Consumer

Consumer side of the pact

§provider: Provider

Provider side of the pact

§messages: Vec<Message>

List of messages between the consumer and provider.

§metadata: BTreeMap<String, BTreeMap<String, String>>

Metadata associated with this pact file.

§specification_version: PactSpecification

Specification version of this pact

Implementations§

source§

impl MessagePact

source

pub fn spec_version(&self) -> PactSpecification

Returns the specification version of this pact

source

pub fn from_json(file: &str, pact_json: &Value) -> Result<MessagePact>

Creates a MessagePact from a Value struct.

source

pub fn metadata_to_json( &self, pact_spec: &PactSpecification ) -> BTreeMap<String, Value>

Creates a BTreeMap of the metadata of this pact.

source

pub fn default_file_name(&self) -> String

Determines the default file name for the pact. This is based on the consumer and provider names.

source

pub fn from_url(url: &String, auth: &Option<HttpAuth>) -> Result<MessagePact>

Reads the pact file from a URL and parses the resulting JSON into a MessagePact struct

source

pub fn overwrite_pact( &self, path: &Path, pact_spec: PactSpecification ) -> Result<()>

Writes this pact out to the provided file path. All directories in the path will automatically created. If there is already a file at the path, it will be overwritten.

source

pub fn default() -> MessagePact

Returns a default MessagePact struct

source

pub fn default_metadata() -> BTreeMap<String, BTreeMap<String, String>>

Returns the default metadata

Trait Implementations§

source§

impl Clone for MessagePact

source§

fn clone(&self) -> MessagePact

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for MessagePact

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Pact for MessagePact

source§

fn to_json(&self, pact_spec: PactSpecification) -> Result<Value>

Converts this pact to a Value struct.

source§

fn consumer(&self) -> Consumer

Consumer side of the pact
source§

fn provider(&self) -> Provider

Provider side of the pact
source§

fn interactions( &self ) -> Vec<Box<dyn Interaction + Send + Sync + RefUnwindSafe>>

Interactions in the Pact
source§

fn interactions_mut(&mut self) -> Vec<&mut (dyn Interaction + Send + Sync)>

Mutable collection of interactions in the Pact
source§

fn metadata(&self) -> BTreeMap<String, BTreeMap<String, String>>

Pact metadata
source§

fn as_request_response_pact(&self) -> Result<RequestResponsePact>

Attempt to downcast to a concrete Pact
source§

fn as_message_pact(&self) -> Result<MessagePact>

Attempt to downcast to a concrete Message Pact
source§

fn as_v4_pact(&self) -> Result<V4Pact>

Attempt to downcast to a concrete V4 Pact
source§

fn specification_version(&self) -> PactSpecification

Specification version of this Pact
source§

fn boxed(&self) -> Box<dyn Pact + Send + Sync + RefUnwindSafe>

Clones this Pact and wraps it in a Box
source§

fn arced(&self) -> Arc<dyn Pact + Send + Sync + RefUnwindSafe>

Clones this Pact and wraps it in an Arc
source§

fn thread_safe(&self) -> Arc<Mutex<dyn Pact + Send + Sync + RefUnwindSafe>>

Clones this Pact and wraps it in an Arc and Mutex
source§

fn add_interaction(&mut self, interaction: &dyn Interaction) -> Result<()>

Adds an interactions in the Pact
source§

fn requires_plugins(&self) -> bool

If this Pact needs any plugins loaded
source§

fn plugin_data(&self) -> Vec<PluginData>

Plugins required for this Pact. These will be taken from the ‘plugins’ key in the pact metadata.
source§

fn is_v4(&self) -> bool

If this is a V4 Pact
source§

fn add_plugin( &mut self, _name: &str, _version: &str, _plugin_data: Option<HashMap<String, Value>> ) -> Result<()>

Add the plugin and plugin data to this Pact. If an entry already exists for the plugin, the plugin data will be merged
source§

fn add_md_version(&mut self, key: &str, version: &str)

Adds some version info to the Pact-Rust metadata section
source§

impl PactJsonVerifier for MessagePact

source§

fn verify_json( path: &str, pact_json: &Value, _strict: bool, _spec_version: PactSpecification ) -> Vec<PactFileVerificationResult>

Verify the JSON format. Will return an error if the list contains any Error result
source§

impl PartialEq for MessagePact

source§

fn eq(&self, other: &MessagePact) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ReadWritePact for MessagePact

source§

fn read_pact(path: &Path) -> Result<MessagePact>

Reads the pact file and parses the resulting JSON into a Pact struct
source§

fn merge( &self, pact: &dyn Pact ) -> Result<Box<dyn Pact + Send + Sync + RefUnwindSafe>>

Merges this pact with the other pact, and returns a new Pact with the interactions sorted. Returns an error if there is a merge conflict, which will occur if the other pact is a different type, or if a V3 Pact then if any interaction has the same description and provider state and the requests and responses are different.
source§

fn default_file_name(&self) -> String

Determines the default file name for the pact. This is based on the consumer and provider names.
source§

impl StructuralPartialEq for MessagePact

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

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

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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