Skip to main content

Overview

Logo of the project

Pact-Rust Build Windows Build status

Pact implementation written in Rust.

This project provides a Pact implementation written in Rust. It supports the V3 Pact specification and V4 Pact specification and provides shared libraries that can be used in other languages via foreign function interfaces (FFI).

Installing / Getting started#

Rust Projects#

The project crates are published to crates.io, and you can use them directly.

Consumer Projects#

For a Rust consumer, refer to the pact_consumer crate.

You can find examples where the integration to the Pact Broker is tested using Pact tests written with the pact_consumer crate.

Verifying Providers#

To verify a provider, you can use the verifier CLI tool. See Pact Verifier CLI.

FFI Interface#

Other languages can use the core features through FFI shared libraries. These libraries expose functions that follow a C calling convention.

Consumer Projects#

For example for a project using Conan and CMake that links to the pact-ffi crate, see Pact-C++.

Verifying Providers#

TODO after merging FFI libs

Developing#

There are 8 main crates to this implementation:

pact_models#

This is a library that provides the Pact models and functions for reading and writing pact files.

pact_matching#

This is a library that provides the Pact functions for matching requests and responses.

pact_ffi#

This is a library that implements exported functions using C bindings for use in foreign languages.

pact_mock_server#

This is a library that provides an in-process mock server for Pact client tests. It uses the pact_matching library.

pact_mock_server_cli#

This module provides a command line executable that provides a standalone pact mock server and commands for controlling the mock servers. It uses the libpact_mock_server and libpact_matching libraries.

pact_consumer#

This is a library that provides the Pact consumer test support and DSL for use in Rust projects.

pact_verifier#

This library provides support for verifying a provider against pact files.

pact_verifier_cli#

Command line excutable that uses the pact_verifier to be able to verify a running provider against pact files.

Building#

To build the libraries in this project, you need a working Rust environment. Refer to the Rust Guide.

The build tool used is cargo.

cd rust
cargo build

This will compile all the libraries and put the generated files in rust/target/debug.

Releasing#

The released libraries for each module are built by a GH action that attaches the libraries to the GH release for each crate. To release a crate, run the release.groovy script in the crate directory. This will guide you through the release process for the crate. Then create a GH release using the tag and changelog created by the script.

Contributing#

See CONTRIBUTING (PRs are always welcome!).

Documentation#

Rust crate documentation is published to the Rust documentation site.

Additional documentation can be found at the main Pact website.

Contact#

Join us in slack: slack

or

Licensing#

The code in this project is licensed under a MIT license. See LICENSE.

Last updated on by Github Action