facet 0.1.1

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

facet

experimental free of syn crates.io documentation MIT/Apache-2.0 licensed

Thanks to all individual and corporate sponsors, without whom this work could not exist:

facet provides runtime reflection for Rust.

Any type that implements Facet trait returns a Shape, which describes:

  • The memory layout of the type
  • Its definition: struct fields, underlying type for newtypes, etc.
  • How to drop it in place

The Poke type is able to allocate (or work from a &mut MaybeUninit<T>) any Facet type, and gradually initialize its fields — until the fully-built value is moved out of the partial.

The Peek type helps perform read operations on any Facet type.

It comes with a derive macro that uses unsynn for speed of compilation.

Ecosystem

The main facet crate re-exports symbols from:

  • facet-trait, which defines the main Facet trait and implements it for foreign types (mostly libstd)
  • facet-types, which defines the Shape struct, along with various vtables and the whole Def tree
  • facet-opaque, which provides helpers around type-erased pointers like OpaqueUninit, OpaqueConst, Opaque
  • facet-derive, which implements the Facet derive attribute as a fast/light proc macro powered by unsynn
  • facet-spez, which implements an autoderef specialization trick needed for facet-derive
  • facet-peek, which allows reading arbitrary Facet types
  • facet-poke, which allows building/altering arbitrary Facet types

facet supports deserialization from multiple data formats through dedicated crates:

Additionally:

Example usage

facet-json is the one that gets updated first — look at it.

License

Licensed under either of:

at your option.