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.
facet-json →Serialize and deserialize Facet types as JSON, with span-aware errors.
figue →Read CLI args, environment variables, config files, and defaults into one type.
facet-pretty →Pretty-print Facet values with structure, color, and sensitive-field redaction.
rediff →Compare Facet values structurally and get path-aware difference reports.
strid →Define strongly-typed string identifiers without the usual wrapper boilerplate.
facet-axum →Use Facet-backed extractors and responses at axum web boundaries.
rusqlite-facet →Bind SQLite query parameters and map rows through Facet-reflected structs.
facet-cargo-toml →Parse Cargo manifests and lockfiles into typed Rust models.
Styx →Write typed documents with minimal punctuation and one obvious meaning.
picante →Build Tokio-first incremental queries with memoization and dependency tracking.
dibs →Model Postgres schemas as Rust and queries as Styx, with migrations included.
fable →Run a tiny typed language over Facet-reflected values, lowered toward Weavy IR.
weavy →Share lowered programs across interpreters and copy-and-patch backends.
vox →Define Rust-native RPC services with cross-language codegen and transports.
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.