pub unsafe trait RawConvertable: Deref {
    type Metadata: Sized;

    // Required methods
    fn into_raw(this: Self) -> (NonNull<Self::Target>, Self::Metadata);
    unsafe fn from_raw(
        pointer: NonNull<Self::Target>,
        metadata: Self::Metadata
    ) -> Self;
}
Expand description

Smart pointers that can convert themselves into raw forms, and is able to convert raw forms back to themselves.

Safety

The implementor of this trait must enable any valid raw form to be converted back to its corresponding valid smart pointer.

Required Associated Types§

source

type Metadata: Sized

The additional metadata needed to be converted back.

Required Methods§

source

fn into_raw(this: Self) -> (NonNull<Self::Target>, Self::Metadata)

Converts a smart pointer into its raw form.

source

unsafe fn from_raw( pointer: NonNull<Self::Target>, metadata: Self::Metadata ) -> Self

Converts the raw form of a smart pointer back.

Safety

pointer and metadata must be the ones that is previously returned from the same call of into_raw.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T, A: Allocator + Clone> RawConvertable for Rc<T, A>

source§

fn into_raw(this: Self) -> (NonNull<T>, A)

See Rc::into_raw and Rc::allocator for more information.

source§

unsafe fn from_raw(pointer: NonNull<T>, metadata: A) -> Self

See Rc::from_raw_in for more information.

§

type Metadata = A

source§

impl<T, A: Allocator + Clone> RawConvertable for Arc<T, A>

source§

fn into_raw(this: Self) -> (NonNull<T>, A)

See Rc::into_raw and Rc::allocator for more information.

source§

unsafe fn from_raw(pointer: NonNull<T>, metadata: A) -> Self

See Rc::from_raw_in for more information.

§

type Metadata = A

source§

impl<T, A: Allocator> RawConvertable for Box<T, A>

source§

fn into_raw(this: Self) -> (NonNull<T>, A)

See Box::into_raw_with_allocator for more information.

source§

unsafe fn from_raw(pointer: NonNull<T>, metadata: A) -> Self

See Box::from_raw_in for more information.

§

type Metadata = A

Implementors§