Macros for generating Rust types from TOML Pacts, and deriving Pact codecs for Rust types.
Generating Rust Types from TOML Pacts
The [macro@pact_toml] macro generates Rust types from a string containing valid Pact TOML:
# use pact_toml;
# use ;
// The annotated string can be an anonymous
// constant like `_`, since it will be replaced
// entirely by the generated code.
const _: &str = r#"
pact = "MyExample"
[entry.1. Request]
message = 'string'
[entry.2. Response]
message = 'string'
"#;
#
Deriving Pact Entry Codecs for Rust Types
The derive(PactCodec) macro derives an entry encoder and decoder ("codec") for a Rust struct:
# use PactCodec;
# use ;
#
#
If a struct represents an entry in a Pact,
an ordinal for the entry may be specified
by adding #[pact(ordinal = 96)] to the struct,
where 96 is an example ordinal.
If a field is not Pact-encodable, or should
not be included during encoding or decoding,
it may be annotated with the
#[pact(ignore = true)] attribute.
License
Copyright 2024 Alicorn Systems, Inc.
Licensed under the GNU Affero General Public License version 3, as published by the Free Software Foundation. Refer to the license file for more information.
If you have any questions, please reach out to [hello@alicorn.systems].