devela::_dep::rkyv::de::pooling

Trait SharedPointer

pub unsafe trait SharedPointer<T>
where T: Pointee + ?Sized,
{ // Required methods fn alloc(metadata: <T as Pointee>::Metadata) -> Result<*mut T, LayoutError> ; unsafe fn from_value(ptr: *mut T) -> *mut T; unsafe fn drop(ptr: *mut T); }
Available on crate feature dep_rkyv only.
Expand description

A deserializable shared pointer type.

§Safety

alloc and from_value must return pointers which are non-null, writeable, and properly aligned for T.

Required Methods§

fn alloc(metadata: <T as Pointee>::Metadata) -> Result<*mut T, LayoutError>

Allocates space for a value with the given metadata.

unsafe fn from_value(ptr: *mut T) -> *mut T

Creates a new Self from a pointer to a valid T.

§Safety

ptr must have been allocated via alloc. from_value must not have been called on ptr yet.

unsafe fn drop(ptr: *mut T)

Drops a pointer created by from_value.

§Safety
  • ptr must have been created using from_value.
  • drop must only be called once per ptr.

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.

Implementors§

§

impl<T> SharedPointer<T> for Rc<T>
where T: LayoutRaw + Pointee + ?Sized,

§

impl<T> SharedPointer<T> for Arc<T>
where T: LayoutRaw + Pointee + ?Sized,