Shared bounded Wire contracts

Public SDK methods and controlled peer protocols use the Serde/Postcard codec through this crate. The SDK pins the published IC Wire release in its manifest. See the Wire guide for the endpoint contract.

encode and decode wrap logical values in a sparse message root under Limits. encode_request/decode_request and response counterparts use the explicit method/direction envelope. Decoding consumes the complete input without a second canonicalizing pass. DEFAULT_LIMITS is the public endpoint default.

Owned encoding measures the admitted size before writing. Generated replies first try stack output. Wire manages temporary extension storage within the encoder's limits. Allocation accounting includes visited input values and the encoded-byte allowance. Custom serializers must be deterministic across sizing and writing.

WireType derive and its registry are native-only schema tooling. They preserve Serde field/variant declaration order and never create Wasm interface tables. Shared DTO crates can use this crate without depending on the IC runtime. Nat and Int have canonical minimal magnitudes, numeric ordering and checked conversions. Principal is the direct ic_principal type with its byte encoding.

Host TypeScript generation uses the official upstream runtime plus the SDK's semantic adapter for Principal, Nat and Int. createMethodCodec composes bounded request/response payload codecs; standalone createPayloadCodec takes {schema, bytes, nodes, depth}. Serialization and parsing stay upstream. The artifact tool exports .runtime.mts and .codec.mts; the canonical builder uses Node 24 or newer to transform them into .mjs, without a stored JavaScript codec copy. See building for generated artifact names.

Client codecs freeze metadata, the registry and reachable schema structure for their whole lifetime; metadata accessors reject. Change contracts by constructing a new codec with new metadata. User payload values remain mutable.

Package guides

Wire guide.