Trait dyn_sized::DynSized
[−]
[src]
pub unsafe trait DynSized { type Meta: Copy; fn assemble(meta: Self::Meta, data: *const ()) -> *const Self; fn disassemble(ptr: *const Self) -> (Self::Meta, *const ()); fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self { ... } fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ()) { ... } fn meta(&self) -> Self::Meta { ... } fn data(&self) -> *const () { ... } fn data_mut(&mut self) -> *mut () { ... } }
A trait for dynamically sized types, similar in principle to the Sized
trait. Allows conversion between fat and thin pointers.
The assemble and disassemble methods must be safe, i.e. they must not dereference the raw pointers, only use them to extract the metadata in the case of disassemble
, or to combine with metadata to produce a fat pointer, in the case of assemble
.
Unsafety
The trait is marked unsafe
, because implementing it wrong can cause undefined behaviour.