Struct pact_models::sync_pact::RequestResponsePact
source · pub struct RequestResponsePact {
pub consumer: Consumer,
pub provider: Provider,
pub interactions: Vec<RequestResponseInteraction>,
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.
Fields§
§consumer: Consumer
Consumer side of the pact
provider: Provider
Provider side of the pact
interactions: Vec<RequestResponseInteraction>
List of interactions 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 RequestResponsePact
impl RequestResponsePact
sourcepub fn spec_version(&self) -> PactSpecification
pub fn spec_version(&self) -> PactSpecification
Returns the specification version of this pact
sourcepub fn from_json(source: &str, pact_json: &Value) -> Result<RequestResponsePact>
pub fn from_json(source: &str, pact_json: &Value) -> Result<RequestResponsePact>
Creates a Pact
from a Value
struct.
sourcepub fn metadata_to_json(
&self,
pact_spec: &PactSpecification,
) -> BTreeMap<String, Value>
pub fn metadata_to_json( &self, pact_spec: &PactSpecification, ) -> BTreeMap<String, Value>
Creates a BTreeMap of the metadata of this pact.
sourcepub fn from_url(
url: &str,
auth: &Option<HttpAuth>,
) -> Result<RequestResponsePact>
pub fn from_url( url: &str, auth: &Option<HttpAuth>, ) -> Result<RequestResponsePact>
Reads the pact file from a URL and parses the resulting JSON into a Pact
struct
sourcepub fn default() -> RequestResponsePact
pub fn default() -> RequestResponsePact
Returns a default RequestResponsePact struct
sourcepub fn default_metadata() -> BTreeMap<String, BTreeMap<String, String>>
pub fn default_metadata() -> BTreeMap<String, BTreeMap<String, String>>
Returns the default metadata
sourcepub fn schema(spec_version: PactSpecification) -> Value
pub fn schema(spec_version: PactSpecification) -> Value
Generate the JSON schema properties for the given Pact specification
Trait Implementations§
source§impl Clone for RequestResponsePact
impl Clone for RequestResponsePact
source§fn clone(&self) -> RequestResponsePact
fn clone(&self) -> RequestResponsePact
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RequestResponsePact
impl Debug for RequestResponsePact
source§impl Default for RequestResponsePact
impl Default for RequestResponsePact
source§fn default() -> RequestResponsePact
fn default() -> RequestResponsePact
Returns the “default value” for a type. Read more
source§impl Pact for RequestResponsePact
impl Pact for RequestResponsePact
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 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 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 RequestResponsePact
impl PactJsonVerifier for RequestResponsePact
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 RequestResponsePact
impl PartialEq for RequestResponsePact
source§impl ReadWritePact for RequestResponsePact
impl ReadWritePact for RequestResponsePact
source§fn read_pact(path: &Path) -> Result<RequestResponsePact>
fn read_pact(path: &Path) -> Result<RequestResponsePact>
Reads the pact file and parses the resulting JSON into a
Pact
structsource§fn merge(
&self,
pact: &dyn Pact,
) -> Result<Box<dyn Pact + Send + Sync + RefUnwindSafe>>
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
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 RequestResponsePact
Auto Trait Implementations§
impl Freeze for RequestResponsePact
impl RefUnwindSafe for RequestResponsePact
impl Send for RequestResponsePact
impl Sync for RequestResponsePact
impl Unpin for RequestResponsePact
impl UnwindSafe for RequestResponsePact
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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