Skip to content
/ facet Public

Rust reflection, serialization, deserialization, pretty printing, etc. — the last proc macro you should need

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

facet-rs/facet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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:

Ko-fi 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.

About

Rust reflection, serialization, deserialization, pretty printing, etc. — the last proc macro you should need

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

 
 
 

Languages