Macros for generating Rust types from TOML Pacts, and deriving Pact codecs for Rust types.
Generating Rust Types from TOML Pacts
The pact_toml macro generates
Rust types from a string containing a Pact TOML:
# use pact_toml;
# use *;
// The string can be an anonymous constant like `_`;
// it will be fully replaced by the generated code.
const _: &str = r#"
pact = "MyGreeter"
[data.1. Request]
message = 'string'
[data.2. Response]
message = 'string'
"#;
#
Deriving Pact Entry Codecs for Rust Types
The derive(PactCodec) macro derives
a pact codec (encoder and decoder) for a Rust struct:
# use PactCodec;
# use *;
#
#
If a struct represents a data type in a Pact,
an ordinal for the data type 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].