Skip to main content

Module compact

Module compact 

Expand description

Compact wire keys (docs/design/compact-wire-keys.md, proposal C): the type trees that let a codec swap a body’s field names for integers.

A key table is a pure function of an op contract (op_contract_json): for every model, type and view in the op’s closure, key n is the n-th entry of that type’s fields array (already sorted by name, @server_only removed), and the Args wrapper of a procedure is numbered by procedure.args, in declaration order. Numbers need not be stable across versions, because every version’s tree is addressed by its own op contract digest, which the client names in the Cratestack-Contract header (ContractSelector).

This module holds the data model (KeyTables, KeyNode), the derivation from a contract, and the artifact generated clients and servers embed (KeyTables::to_bytes). The byte rewriting itself lives in cratestack-codec-cbor and cratestack-codec-json.

Structs§

KeyStruct
One struct: its fields in key order, so field n has key n.
KeyTables
The key tables of a schema (or of a server’s accepted contracts).
OpKeys
One op at one contract digest.

Enums§

CompactError
Why a key table could not be built or read.
Direction
Which side of an op a node describes.
KeyNode
A type tree node: how the keys of one value are numbered.

Constants§

COMPACT_CBOR
A CBOR body whose schema-declared field names are integer keys.
COMPACT_CBOR_SEQ
A CBOR sequence (@stream, subscriptions) of compact CBOR items.
COMPACT_JSON
A JSON body whose schema-declared field names are decimal-string keys.

Functions§

compact_media_type_for
The compact type of a plain payload type: application/cbor, application/json or application/cbor-seq. Anything else has none.
plain_media_type_for
The plain type a compact type stands for; the inverse of compact_media_type_for.