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
impl V4Pact
sourcepub fn has_interactions(&self, interaction_type: V4InteractionType) -> bool
pub fn has_interactions(&self, interaction_type: V4InteractionType) -> bool
If this Pact has any interactions of the given type
sourcepub fn has_mixed_interactions(&self) -> bool
pub fn has_mixed_interactions(&self) -> bool
If this Pact has different types of interactions
sourcepub fn filter_interactions(
&self,
interaction_type: V4InteractionType
) -> Vec<Box<dyn Interaction + Send + Sync + RefUnwindSafe>>
pub fn filter_interactions( &self, interaction_type: V4InteractionType ) -> Vec<Box<dyn Interaction + Send + Sync + RefUnwindSafe>>
Returns all the interactions of the given type
sourcepub fn find_interaction_with_id(
&self,
interaction_id: &str
) -> Option<&Box<dyn V4Interaction + Send + Sync + RefUnwindSafe>>
pub fn find_interaction_with_id( &self, interaction_id: &str ) -> Option<&Box<dyn V4Interaction + Send + Sync + RefUnwindSafe>>
Find the interaction with the given ID
Trait Implementations§
source§impl Pact for V4Pact
impl Pact for V4Pact
source§fn interactions(
&self
) -> Vec<Box<dyn Interaction + Send + Sync + RefUnwindSafe>>
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)>
fn interactions_mut(&mut self) -> Vec<&mut (dyn Interaction + Send + Sync)>
Mutable collection of interactions in the Pact
source§fn to_json(&self, pact_spec: PactSpecification) -> Result<Value>
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>
fn as_request_response_pact(&self) -> Result<RequestResponsePact>
Attempt to downcast to a concrete Pact
source§fn as_message_pact(&self) -> Result<MessagePact>
fn as_message_pact(&self) -> Result<MessagePact>
Attempt to downcast to a concrete Message Pact
source§fn as_v4_pact(&self) -> Result<V4Pact>
fn as_v4_pact(&self) -> Result<V4Pact>
Attempt to downcast to a concrete V4 Pact
source§fn specification_version(&self) -> PactSpecification
fn specification_version(&self) -> PactSpecification
Specification version of this Pact
source§fn boxed(&self) -> Box<dyn Pact + Send + Sync + RefUnwindSafe>
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>
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>>
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<()>
fn add_interaction(&mut self, interaction: &dyn Interaction) -> Result<()>
Adds an interactions in the Pact
source§fn requires_plugins(&self) -> bool
fn requires_plugins(&self) -> bool
If this Pact needs any plugins loaded
source§fn plugin_data(&self) -> Vec<PluginData>
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 add_plugin(
&mut self,
name: &str,
version: &str,
plugin_data: Option<HashMap<String, Value>>
) -> Result<()>
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)
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
impl PactJsonVerifier for V4Pact
source§fn verify_json(
_path: &str,
pact_json: &Value,
_strict: bool,
_spec_version: PactSpecification
) -> Vec<PactFileVerificationResult>
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
impl PartialEq for V4Pact
source§impl ReadWritePact for V4Pact
impl ReadWritePact for V4Pact
source§fn read_pact(path: &Path) -> Result<V4Pact>
fn read_pact(path: &Path) -> Result<V4Pact>
Reads the pact file and parses the resulting JSON into a
Pact
structsource§fn merge(
&self,
other: &dyn Pact
) -> Result<Box<dyn Pact + Send + Sync + RefUnwindSafe>>
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
fn default_file_name(&self) -> String
Determines the default file name for the pact. This is based on the consumer and
provider names.
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> 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
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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