devela::_dep::rkyv::ptr_meta

Trait Pointee

pub unsafe trait Pointee {
    type Metadata: Copy + Send + Sync + Ord + Hash + Unpin;
}
Available on crate feature dep_rkyv only.
Expand description

A trait which associates pointer metadata with a pointee type.

§Pointer metadata

Pointers and references can be thought of as having two parts: a data address and some extra “pointer metadata”.

Pointers to statically-sized types and extern types are “narrow”: their pointer metadata is ().

Pointers to dynamically-sized types are “wide”: they have pointer metadata with a non-zero size. There are four classes of dynamically-sized types currently available:

  • strs have usize pointer metadata equal to the length of the string slice in bytes.
  • Slices like [i32] have usize pointer metadata equal to the length of the slice in items.
  • Trait objects like dyn SomeTrait have DynMetadata pointer metadata, which point to the trait objects’ virtual method tables.
  • Structs with a trailing DST have the same metadata as the trailing DST.

In the future, Rust may add new kinds of types which have different pointer metadata.

§Safety

The associated Metadata type must be the pointer metadata type for the implementing type.

Required Associated Types§

type Metadata: Copy + Send + Sync + Ord + Hash + Unpin

The metadata type for pointers and references to this type.

Implementations on Foreign Types§

§

impl Pointee for str

§

impl<T> Pointee for [T]

Implementors§

§

impl Pointee for CStr

§

impl Pointee for OsStr

§

impl Pointee for dyn Error

§

impl Pointee for dyn Error + Send

§

impl Pointee for dyn Error + Send + Sync

§

impl Pointee for dyn Error + Sync

§

impl Pointee for dyn Any

§

impl Pointee for dyn Any + Send

§

impl Pointee for dyn Any + Send + Sync

§

impl Pointee for dyn Any + Sync

§

impl<T> Pointee for T

§

type Metadata = ()