<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/facet-rs/facet/raw/main/static/logo/facet-dark.webp">
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/facet-rs/facet/raw/main/static/logo/facet-dark.png">
<source media="(prefers-color-scheme: light)" srcset="https://github.com/facet-rs/facet/raw/main/static/logo/facet-light.webp">
<img src="https://github.com/facet-rs/facet/raw/main/static/logo/facet-light.png" alt="Facet logo - a reflection library for Rust">
</picture>
# facet-trait
[](https://github.com/fasterthanlime/facet)
[](https://github.com/fasterthanlime/free-of-syn)
[](https://crates.io/crates/facet-trait)
[](https://docs.rs/facet-trait)
[](./LICENSE)
Thanks to all individual and corporate sponsors, without whom this work could not exist:
<p> <a href="https://ko-fi.com/fasterthanlime">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/facet-rs/facet/raw/main/static/sponsors-v2/ko-fi-dark.svg">
<img src="https://github.com/facet-rs/facet/raw/main/static/sponsors-v2/ko-fi-light.svg" height="40" alt="Ko-fi">
</picture>
</a> <a href="https://github.com/sponsors/fasterthanlime">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/facet-rs/facet/raw/main/static/sponsors-v2/github-dark.svg">
<img src="https://github.com/facet-rs/facet/raw/main/static/sponsors-v2/github-light.svg" height="40" alt="GitHub Sponsors">
</picture>
</a> <a href="https://patreon.com/fasterthanlime">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/facet-rs/facet/raw/main/static/sponsors-v2/patreon-dark.svg">
<img src="https://github.com/facet-rs/facet/raw/main/static/sponsors-v2/patreon-light.svg" height="40" alt="Patreon">
</picture>
</a> <a href="https://zed.dev">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/facet-rs/facet/raw/main/static/sponsors-v2/zed-dark.svg">
<img src="https://github.com/facet-rs/facet/raw/main/static/sponsors-v2/zed-light.svg" height="40" alt="Zed">
</picture>
</a> </p>
Defines the core `Facet` trait that powers runtime reflection in the facet ecosystem.
### The Facet Trait
The `Facet` trait is the foundation of facet's reflection system. Types that implement `Facet`:
* Provide their memory layout information
* Describe their structure (fields, variants, etc.)
* Enable safe runtime manipulation
* Can be safely type-erased and restored
### Built-in Implementations
This crate provides `Facet` implementations for many standard library types:
* Basic types (`bool`, integers, floats)
* Collections (`Vec`, `HashMap`, etc.)
* Smart pointers (`Box`, `Rc`, `Arc`)
* Other common types (`String`, `Option`, `Result`)
These implementations make it easy to use facet with existing Rust code.
## License
Licensed under either of:
- Apache License, Version 2.0 ([LICENSE-APACHE](https://github.com/facet-rs/facet/blob/main/LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT license ([LICENSE-MIT](https://github.com/facet-rs/facet/blob/main/LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
at your option.