MetaData

Trait MetaData 

Source
pub unsafe trait MetaData {
    type Data: Copy + Eq;

    // Required methods
    fn data(this: &Self) -> Self::Data;
    unsafe fn compose(ptr: Ptr<u8>, data: Self::Data) -> Ptr<Self>;
}
Expand description

A trait to abstract over the sizedness of types, and to access metadata about a type

If Custom DST lands and stablizes, then it will replace MetaData

Required Associated Types§

Source

type Data: Copy + Eq

the type of meta data a type carries

Required Methods§

Source

fn data(this: &Self) -> Self::Data

decompose a type into a thin pointer and some metadata

Source

unsafe fn compose(ptr: Ptr<u8>, data: Self::Data) -> Ptr<Self>

recompose a type from a thin pointer and some metadata

it is guarenteed that the metadata is

  • ptr == None Self::Data is undefined
  • ptr != None generated from MetaData::data

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 MetaData for str

Source§

type Data = usize

Source§

fn data(this: &Self) -> Self::Data

Source§

unsafe fn compose(ptr: Ptr<u8>, data: Self::Data) -> Ptr<Self>

Source§

impl<T> MetaData for [T]

Source§

type Data = usize

Source§

fn data(this: &Self) -> Self::Data

Source§

unsafe fn compose(ptr: Ptr<u8>, data: Self::Data) -> Ptr<Self>

Implementors§

Source§

impl<T> MetaData for T