loom-serialization
Installation
SKILL.md
Serialization
Overview
Converting in-memory data to bytes for storage/transport and back. The hard problems are not encode/decode calls — they are schema evolution (old and new code exchanging data safely), format choice (self-describing vs schema'd, text vs binary), and correctness traps (int64 precision, NaN, non-deterministic output, unknown-field handling). This skill is mechanism-level; assume you can call the library.
Format Selection
| Format | Schema | Self-describing | Cross-lang | Notes / when to reach for it |
|---|---|---|---|---|
| JSON | none | yes | yes | Debuggable, ubiquitous. No int64/binary/date types; slow; large. Default for public HTTP APIs. |
| Protobuf | IDL (.proto) |
no (tag numbers only) | excellent | Compact, tag-based evolution, gRPC. Needs .proto to read bytes. |
| Avro | required (writer+reader) | schema travels or via registry | good | No per-field tags/names in payload → smallest tagged binary; schema-resolution evolution. Kafka/Hadoop. |
| MessagePack | none | yes | yes | "binary JSON": same data model, ~2x smaller/faster. Dynamic data without a schema. |
| CBOR (RFC 8949) | none | yes | yes | IETF-standard MessagePack cousin; has a canonical form + tags. COSE/WebAuthn/DTLS. |
| FlatBuffers / Cap'n Proto | IDL | no | good | Zero-copy: read fields without parsing; mmap-able. Games, low-latency IPC. |
| bincode / postcard | Rust type layout | no | no (Rust↔Rust) | Fastest+smallest for Rust-only. No evolution — field order/type is the contract. |
| TOML / YAML | none | yes | yes | Config, human-authored. Not for hot-path data (YAML esp. slow + footguns). |