Skip to main content

Module codecs

Module codecs 

Source

Structs§

Bson
Built-in BSON codec (bson, behind the native-only bson feature: its dependency tree does not build on wasm32-unknown-unknown). Self-describing like JSON. The top-level body must be a document (struct or map).
Cbor
Built-in CBOR codec (ciborium). Self-describing like JSON, so LaserData Cloud’s projector can index its fields without a schema. Constrains the body to Serialize / DeserializeOwned.
Json
Built-in JSON codec (serde_json). Constrains the body to Serialize.
Msgpack
Built-in MessagePack codec (rmp_serde, named-map encoding so field names round-trip with JSON-shaped consumers). Constrains the body to Serialize.

Traits§

Codec
Encoding strategy for a typed body. Four first-party codecs ship here, all self-describing so LaserData Cloud’s projector can index their fields without a schema: Json (serde_json), Msgpack (rmp_serde), Cbor (ciborium), and Bson (bson, native-only feature). For a schema-first format (Avro or Protobuf), Arrow, or your own framing, implement Codec on a marker type. The codec advertises its ContentType so consumers can decode downstream.
Decoder
The decode half of a codec. Separate from Codec because encoding is ?Sized (you can encode a &str) while decoding must produce an owned, deserializable value. Json, Msgpack, Cbor, and Bson implement both. A custom codec (Avro, Protobuf, Arrow, or your own framing) implements only the half it needs.