pact 0.1.1

Compact data format and streaming codec.
Documentation

Compact data format and streaming codec that's easy to embed on any platform, from web apps to robots.

What's a Pact?

A pact describes the structure of related groups of data called entries, each containing one or more fields.

Pact entries can have the following kinds of fields:

  1. Unsigned integers from 8 to 64 bits (u8, u16, u32, and u64).
  2. Signed integers from 8 to 64 bits (i8, i16, i32, and i64).
  3. Signed floating-point integers from 32 to 64 bits (f32 and f64).
  4. Booleans (boolean).
  5. Variable-length strings (string).
  6. Nested entries.
  7. Arrays of any of the things listed above.

For information on how pact data is coded to and from binary data, refer to the codec docs.

How do I make a Pact?

Pacts are made using TOML:

## An example pact.
pact = 'MyGreeter'

## A group of data in this
## pact named 'Request'.
[entry.1. Request]
message = 'string'

## Another group of data
## in this pact named
## 'Response'.
[entry.2. Response]
message = 'string'

## This field of Response is an
## array of strings, instead of just
## a single string, because it is
## surrounded by `[]`.
friends = ['string']

This TOML describes the MyGreeter pact, and declares two kinds of entries: Request and Response. Both entries contain a variable-length message string, and the Response entry contains an array of strings called friends.

Every entry description starts with a number called an Ordinal. Ordinals uniquely identify the different kinds of entries in the same pact. The first entry described by a pact always has ordinal 1, and each additional entry in the same pact has an ordinal that is one higher than the previous data.

Comments that start with ## and come immediately before the pact name, a entry name, or a field name, will be parsed as documentation for the item they precede.

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].