#reflection #pretty-print #introspection

no-std facet

Re-exports the Facet trait and derive macros, along with Shape and all related types

76 releases (15 breaking)

Uses new Rust 2024

0.31.3 Oct 31, 2025
0.30.0 Oct 18, 2025
0.28.0 Jul 24, 2025

#18 in Procedural macros

Download history 976/week @ 2025-07-23 1013/week @ 2025-07-30 1351/week @ 2025-08-06 1384/week @ 2025-08-13 2007/week @ 2025-08-20 2424/week @ 2025-08-27 2474/week @ 2025-09-03 2969/week @ 2025-09-10 2184/week @ 2025-09-17 1912/week @ 2025-09-24 3010/week @ 2025-10-01 3577/week @ 2025-10-08 2340/week @ 2025-10-15 2663/week @ 2025-10-22 2296/week @ 2025-10-29 1751/week @ 2025-11-05

9,636 downloads per month
Used in 56 crates (44 directly)

MIT/Apache

670KB
13K SLoC

facet

Coverage Status crates.io documentation MIT/Apache-2.0 licensed Discord

facet provides reflection for Rust: it gives types a SHAPE associated const with details on the layout, fields, doc comments, attributes, etc.

It can be used for many things, from (de)serialization to pretty-printing, rich debuggers, CLI parsing, reflection in templating engines, code generation, etc.

See https://facet.rs for details.

Workspace contents

The main facet crate re-exports symbols from:

  • facet-core, which defines the main components:
    • The Facet trait and implementations for foreign types (mostly libstd)
    • The Shape struct along with various vtables and the whole Def tree
    • Type-erased pointer helpers like PtrUninit, PtrConst, and Opaque
    • Autoderef specialization trick needed for facet-macros
  • facet-macros, which implements the Facet derive attribute as a fast/light proc macro powered by unsynn

For struct manipulation and reflection, we have:

  • facet-reflect, allows building values of arbitrary shapes in safe code, respecting invariants. It also allows peeking at existing values.

Internal crates include:

  • facet-testhelpers a simple log logger and color-backtrace configured with the lightweight btparse backend

Ecosystem

Various crates live under the https://github.com/facet-rs umbrella, and their repositories are kept somewhat-consistent through facet-dev.

Crates are in various states of progress, buyer beware!

In terms of data formats, we have:

Still adjacent to serialization/deserialization, we have:

As far as utilities go:

And the less developed:

  • facet-inspect: Provide utilities to inspect the content of a Facet object.
  • facet-diff: Provides diffing capabilities for Facet types.

Extended cinematic universe

Some crates are developed completely independently from the facet org:

  • facet-v8 provides an experimental Facet/v8 integration
  • facet-openapi (experimental) Generates OpenAPI definitions from types that implement Facet
  • facet_generate reflects Facet types into Java, Swift and TypeScript
  • multi-array-list provides an experimental MultiArrayList type

Sponsors

Thanks to all individual sponsors:

GitHub Sponsors Patreon

...along with corporate sponsors:

AWS Zed Depot

...without whom this work could not exist.

Special thanks

The facet logo was drawn by Misiasart.

License

Licensed under either of:

at your option.

Dependencies

~0.6–2.6MB
~42K SLoC