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 = "bytes")]
36mod impls_bytes;
37
38#[cfg(feature = "camino")]
39mod impls_camino;
40
41#[cfg(feature = "ordered-float")]
42mod impls_ordered_float;
43
44#[cfg(feature = "uuid")]
45mod impls_uuid;
46
47#[cfg(feature = "ulid")]
48mod impls_ulid;
49
50#[cfg(feature = "time")]
51mod impls_time;
52
53#[cfg(feature = "chrono")]
54mod impls_chrono;
55
56#[cfg(feature = "url")]
57mod impls_url;
58
59#[cfg(feature = "jiff02")]
60mod impls_jiff;
61
62#[cfg(feature = "num-complex")]
63mod impls_num_complex;
64
65// Const type Id
66mod typeid;
67pub use typeid::*;
68
69// Type definitions
70mod types;
71#[allow(unused_imports)] // wtf clippy? we're re-exporting?
72pub use types::*;
73
74/// Allows querying the [`Shape`] of a type, which in turn lets us inspect any fields, build a value of
75/// this type progressively, etc.
76///
77/// The `'facet` lifetime allows `Facet` to be derived for types that borrow from something else.
78///
79/// # Safety
80///
81/// If you implement this wrong, all the safe abstractions in `facet-reflect`,
82/// all the serializers, deserializers, the entire ecosystem is unsafe.
83///
84/// You're responsible for describing the type layout properly, and annotating all the invariants.
85pub unsafe trait Facet<'facet>: 'facet {
86    /// The shape of this type
87    ///
88    /// Shape embeds all other constants of this trait.
89    const SHAPE: &'static Shape;
90}
91
92mod shape_util;