facet

Reflection for Rust: derive Facet once, then serialize, inspect, diff, configure, and build tooling from one type description.

Reflection for Rust. Derive Facet once, and your type can describe itself: fields, variants, attributes, shape, and enough structure for other tools to do useful work.

rust
use facet::Facet;

#[derive(Facet)]
struct Config {
    name: String,
    port: u16,
    #[facet(sensitive)]
    api_key: String,
}

That one derive can power JSON, YAML, TOML, MessagePack, pretty-printing with sensitive-field redaction, structural diffing, runtime introspection, CLI parsing, schema generation, and more. The fun part: each tool reads the same source of truth.

Start here

  • Guide — derive Facet, add a format crate, and ship with helpful diagnostics.
  • Ecosystem map — formats, schema generators, config, diffing, UI, and building blocks.
  • Showcases — small examples for derives, pretty-printing, diffing, and HTML.
  • Reference — attributes, extension points, and the format support matrix.

Built on facet

The reflection core is the foundation; these projects build useful things on top of it. Pick the one that matches the job in front of you.

Use facet itself

  • Guide — install a format crate, derive Facet, and ship with great diagnostics.
  • Ecosystem map — every facet crate: formats, schema codegen, CLI, diffing, pretty-printing.
  • Showcases — interactive examples for JSON, YAML, args, diffing, and more.
  • Reference — the attributes catalog and format support matrix.
  • Extend · Contribute — build on reflection, or work on facet itself.

GitHub · crates.io · docs.rs · Discord