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.
The main facet
crate re-exports symbols from:
- facet-core, which defines the main components:
- The
Facet
trait and implementations for foreign types (mostlylibstd
) - The
Shape
struct along with various vtables and the wholeDef
tree - Type-erased pointer helpers like
PtrUninit
,PtrConst
, andOpaque
- Autoderef specialization trick needed for
facet-macros
- The
- 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
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:
- facet-json: JSON format support
- facet-toml: TOML format support
- facet-yaml: YAML format support
- facet-msgpack: MessagePack deserialization
- facet-asn1: ASN.1 format support
- facet-xdr: XDR format support
- facet-kdl: KDL format support (non-functional so far)
Still adjacent to serialization/deserialization, we have:
- facet-urlencoded: URL-encoded form data deserialization
- facet-args: CLI arguments (a-la clap)
As far as utilities go:
- facet-pretty is able to pretty-print Facet types.
- facet-serialize provides generic iterative serialization facilities
- facet-deserialize provides generic iterative deserialization facilities
And the less developed:
- facet-inspect: Provide utilities to inspect the content of a Facet object.
- facet-diff: Provides diffing capabilities for Facet types.
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
Thanks to all individual sponsors:
...along with corporate sponsors:
...without whom this work could not exist.
The facet logo was drawn by Misiasart.
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.