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§
- Compact
Error - 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/jsonorapplication/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.