[][src]Struct pact_matching::models::Pact

pub struct Pact {
    pub consumer: Consumer,
    pub provider: Provider,
    pub interactions: Vec<Interaction>,
    pub metadata: BTreeMap<String, BTreeMap<String, String>>,
    pub specification_version: PactSpecification,
}

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<Interaction>

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

Methods

impl Pact[src]

pub fn spec_version(&self) -> PactSpecification[src]

Returns the specification version of this pact

pub fn from_json(file: &String, pact_json: &Value) -> Pact[src]

Creates a Pact from a Value struct.

pub fn to_json(&self, pact_spec: PactSpecification) -> Value[src]

Converts this pact to a Value struct.

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

Creates a BTreeMap of the metadata of this pact.

pub fn merge(&self, pact: &Pact) -> Result<Pact, String>[src]

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 any interaction has the same description and provider state and the requests and responses are different.

pub fn default_file_name(&self) -> String[src]

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

pub fn read_pact(file: &Path) -> Result<Pact>[src]

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

pub fn from_url(url: &String, auth: &Option<HttpAuth>) -> Result<Pact, String>[src]

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

pub fn write_pact(
    &self,
    path: &Path,
    pact_spec: PactSpecification
) -> Result<()>
[src]

Writes this pact out to the provided file path. All directories in the path will automatically created. If an existing pact is found at the path, this pact will be merged into the pact file.

pub fn default() -> Pact[src]

Returns a default Pact struct

Trait Implementations

impl Clone for Pact[src]

impl Debug for Pact[src]

Auto Trait Implementations

impl RefUnwindSafe for Pact

impl Send for Pact

impl Sync for Pact

impl Unpin for Pact

impl UnwindSafe for Pact

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.