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#[cfg(feature = "ruint")]
66mod impls_ruint;
67
68// Const type Id
69mod typeid;
70pub use typeid::*;
71
72// Type definitions
73mod types;
74#[allow(unused_imports)] // wtf clippy? we're re-exporting?
75pub use types::*;
76
77/// Allows querying the [`Shape`] of a type, which in turn lets us inspect any fields, build a value of
78/// this type progressively, etc.
79///
80/// The `'facet` lifetime allows `Facet` to be derived for types that borrow from something else.
81///
82/// # Safety
83///
84/// If you implement this wrong, all the safe abstractions in `facet-reflect`,
85/// all the serializers, deserializers, the entire ecosystem is unsafe.
86///
87/// You're responsible for describing the type layout properly, and annotating all the invariants.
88pub unsafe trait Facet<'facet>: 'facet {
89    /// The shape of this type
90    ///
91    /// Shape embeds all other constants of this trait.
92    const SHAPE: &'static Shape;
93}
94
95mod shape_util;