Struct pact_models::v4::pact::V4Pact

source ·
pub struct V4Pact {
    pub consumer: Consumer,
    pub provider: Provider,
    pub interactions: Vec<Box<dyn V4Interaction + Send + Sync + RefUnwindSafe>>,
    pub metadata: BTreeMap<String, Value>,
    pub plugin_data: Vec<PluginData>,
}
Expand description

V4 spec Struct that represents a pact between the consumer and provider of a service.

Fields§

§consumer: Consumer

Consumer side of the pact

§provider: Provider

Provider side of the pact

§interactions: Vec<Box<dyn V4Interaction + Send + Sync + RefUnwindSafe>>

List of messages between the consumer and provider.

§metadata: BTreeMap<String, Value>

Metadata associated with this pact.

§plugin_data: Vec<PluginData>

Plugin data associated with this pact

Implementations§

source§

impl V4Pact

source

pub fn has_interactions(&self, interaction_type: V4InteractionType) -> bool

If this Pact has any interactions of the given type

source

pub fn has_mixed_interactions(&self) -> bool

If this Pact has different types of interactions

source

pub fn filter_interactions( &self, interaction_type: V4InteractionType ) -> Vec<Box<dyn Interaction + Send + Sync + RefUnwindSafe>>

Returns all the interactions of the given type

source

pub fn find_interaction_with_id( &self, interaction_id: &str ) -> Option<&Box<dyn V4Interaction + Send + Sync + RefUnwindSafe>>

Find the interaction with the given ID

source

pub fn pact_from_json(json: &Value, source: &str) -> Result<V4Pact>

Parses a JSON value into a V4 Pact model

Trait Implementations§

source§

impl Clone for V4Pact

source§

fn clone(&self) -> V4Pact

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 V4Pact

source§

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

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

impl Default for V4Pact

source§

fn default() -> Self

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

impl Pact for V4Pact

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 to_json(&self, pact_spec: PactSpecification) -> Result<Value>

Converts this pact to a Value struct.
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 V4Pact

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 V4Pact

source§

fn eq(&self, other: &V4Pact) -> 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 V4Pact

source§

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

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

fn merge( &self, other: &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 V4Pact

Auto Trait Implementations§

§

impl Freeze for V4Pact

§

impl RefUnwindSafe for V4Pact

§

impl Send for V4Pact

§

impl Sync for V4Pact

§

impl Unpin for V4Pact

§

impl !UnwindSafe for V4Pact

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