« All posts

Serde-shape reflects Rust's Serde data model without serializing

serde-shape is a Rust crate that reflects Serde's serialization and deserialization data model as an inspectable graph, without running Serde itself.

serde-shape is a new Rust library that builds an inspectable graph of the data model a type emits during Serde serialization or accepts during deserialization — without actually performing serialization or deserialization. It works from type information and #[serde(...)] attributes to expose field names, enum tagging, defaults, aliases, skipped fields, and custom serializer/deserializer boundaries.

The crate provides two independent derive macros, SerializeShape and DeserializeShape, decoupled from Serde's own Serialize/Deserialize derives and with no effect on runtime behavior. This separation matters because Serde allows a type's emitted and accepted representations to differ, and serde-shape lets tools inspect either or both directions independently.

Typical use cases include generating configuration reference docs, deriving environment variable names from nested config structs, documenting API or file-format shapes without handwritten schemas, and tracking how a type's wire representation changes across releases. It is explicitly not a validation schema — it won't infer value ranges or business rules — leaving format-specific export, like JSON Schema, to tools such as schemars.

This synthesis was produced from its source by AI; there is no human editor or manual review step. How we work