facet_core/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2#![warn(missing_docs)]
3#![warn(clippy::std_instead_of_core)]
4#![warn(clippy::std_instead_of_alloc)]
5#![doc = include_str!("../README.md")]
6
7#[cfg(feature = "alloc")]
8extern crate alloc;
9
10mod macros;
11pub use macros::*;
12
13// Opaque pointer utilities
14mod ptr;
15pub use ptr::*;
16
17// Opaque wrapper utility
18mod opaque;
19pub use opaque::*;
20
21// Specialization utilities
22pub mod spez;
23
24// Definition for `core::` types
25mod impls_core;
26
27// Definition for `alloc::` types
28#[cfg(feature = "alloc")]
29mod impls_alloc;
30
31// Definition for `std::` types (that aren't in `alloc` or `core)
32#[cfg(feature = "std")]
33mod impls_std;
34
35#[cfg(feature = "camino")]
36mod impls_camino;
37
38#[cfg(feature = "ordered-float")]
39mod impls_ordered_float;
40
41#[cfg(feature = "uuid")]
42mod impls_uuid;
43
44#[cfg(feature = "ulid")]
45mod impls_ulid;
46
47// Const type Id
48mod typeid;
49pub use typeid::*;
50
51// Type definitions
52mod types;
53#[allow(unused_imports)] // wtf clippy? we're re-exporting?
54pub use types::*;
55
56/// Allows querying the [`Shape`] of a type, which in turn lets us inspect any fields, build a value of
57/// this type progressively, etc.
58///
59/// # Safety
60///
61/// If you implement this wrong, all the safe abstractions in `facet-reflect`,
62/// all the serializers, deserializers, the entire ecosystem is unsafe.
63///
64/// You're responsible for describing the type layout properly, and annotating all the invariants.
65pub unsafe trait Facet<'a>: 'a {
66    /// The shape of this type
67    const SHAPE: &'static Shape;
68}