Trait Facet

Source
pub unsafe trait Facet: Sized {
    const SHAPE: &'static Shape;
    const ARCHETYPE: Self;

    // Provided method
    fn type_eq<Other: Facet>() -> bool { ... }
}
Expand description

Allows querying the Shape of a type, which in turn lets us inspect any fields, build a value of this type progressively, etc.

§Safety

If you implement this wrong, all the safe abstractions in facet-peek, facet-poke, all the serializers, deserializers, the entire ecosystem is unsafe.

You’re responsible for describing the type layout properly, and annotating all the invariants.

Required Associated Constants§

Source

const SHAPE: &'static Shape

The shape of this type

Source

const ARCHETYPE: Self

An instance of this type — which doesn’t have to be valid, but it has to “not be UB”. We never actually read from it, or even actually use it for dynamic dispatch, we only use it for inference tricks.

Provided Methods§

Source

fn type_eq<Other: Facet>() -> bool

Returns true if the type of self is equal to the type of other

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Facet for &str

Source§

const ARCHETYPE: Self = ""

Source§

const SHAPE: &'static Shape

Source§

impl Facet for Cow<'_, str>

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl Facet for bool

Source§

const ARCHETYPE: Self = false

Source§

const SHAPE: &'static Shape

Source§

impl Facet for f32

Source§

const ARCHETYPE: Self = 0f32

Source§

const SHAPE: &'static Shape

Source§

impl Facet for f64

Source§

const ARCHETYPE: Self = 0f64

Source§

const SHAPE: &'static Shape

Source§

impl Facet for i8

Source§

const ARCHETYPE: Self = 0i8

Source§

const SHAPE: &'static Shape

Source§

impl Facet for i16

Source§

const ARCHETYPE: Self = 0i16

Source§

const SHAPE: &'static Shape

Source§

impl Facet for i32

Source§

const ARCHETYPE: Self = 0i32

Source§

const SHAPE: &'static Shape

Source§

impl Facet for i64

Source§

const ARCHETYPE: Self = 0i64

Source§

const SHAPE: &'static Shape

Source§

impl Facet for i128

Source§

const ARCHETYPE: Self = 0i128

Source§

const SHAPE: &'static Shape

Source§

impl Facet for u8

Source§

const ARCHETYPE: Self = 0u8

Source§

const SHAPE: &'static Shape

Source§

impl Facet for u16

Source§

const ARCHETYPE: Self = 0u16

Source§

const SHAPE: &'static Shape

Source§

impl Facet for u32

Source§

const ARCHETYPE: Self = 0u32

Source§

const SHAPE: &'static Shape

Source§

impl Facet for u64

Source§

const ARCHETYPE: Self = 0u64

Source§

const SHAPE: &'static Shape

Source§

impl Facet for u128

Source§

const ARCHETYPE: Self = 0u128

Source§

const SHAPE: &'static Shape

Source§

impl Facet for ()

Source§

const ARCHETYPE: Self = ()

Source§

const SHAPE: &'static Shape

Source§

impl Facet for String

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl Facet for RandomState

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<K, V, S> Facet for HashMap<K, V, S>
where K: Facet + Eq + Hash + 'static, V: Facet + 'static, S: Facet + Default,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<T0> Facet for (T0,)
where T0: Facet,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<T0, T1> Facet for (T0, T1)
where T0: Facet, T1: Facet,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<T0, T1, T2> Facet for (T0, T1, T2)
where T0: Facet, T1: Facet, T2: Facet,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<T0, T1, T2, T3> Facet for (T0, T1, T2, T3)
where T0: Facet, T1: Facet, T2: Facet, T3: Facet,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<T0, T1, T2, T3, T4> Facet for (T0, T1, T2, T3, T4)
where T0: Facet, T1: Facet, T2: Facet, T3: Facet, T4: Facet,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<T0, T1, T2, T3, T4, T5> Facet for (T0, T1, T2, T3, T4, T5)
where T0: Facet, T1: Facet, T2: Facet, T3: Facet, T4: Facet, T5: Facet,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<T0, T1, T2, T3, T4, T5, T6> Facet for (T0, T1, T2, T3, T4, T5, T6)
where T0: Facet, T1: Facet, T2: Facet, T3: Facet, T4: Facet, T5: Facet, T6: Facet,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<T0, T1, T2, T3, T4, T5, T6, T7> Facet for (T0, T1, T2, T3, T4, T5, T6, T7)
where T0: Facet, T1: Facet, T2: Facet, T3: Facet, T4: Facet, T5: Facet, T6: Facet, T7: Facet,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> Facet for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
where T0: Facet, T1: Facet, T2: Facet, T3: Facet, T4: Facet, T5: Facet, T6: Facet, T7: Facet, T8: Facet,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> Facet for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)
where T0: Facet, T1: Facet, T2: Facet, T3: Facet, T4: Facet, T5: Facet, T6: Facet, T7: Facet, T8: Facet, T9: Facet,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Facet for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
where T0: Facet, T1: Facet, T2: Facet, T3: Facet, T4: Facet, T5: Facet, T6: Facet, T7: Facet, T8: Facet, T9: Facet, T10: Facet,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Facet for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)
where T0: Facet, T1: Facet, T2: Facet, T3: Facet, T4: Facet, T5: Facet, T6: Facet, T7: Facet, T8: Facet, T9: Facet, T10: Facet, T11: Facet,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<T> Facet for &[T]
where T: Facet,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<T> Facet for [T; 1]
where T: Facet,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Source§

impl<T> Facet for Vec<T>
where T: Facet,

Source§

const ARCHETYPE: Self

Source§

const SHAPE: &'static Shape

Implementors§