[][src]Trait abi_stable::pointer_trait::ImmutableRef

pub unsafe trait ImmutableRef: Copy {
    type Target;

    pub const TARGET: ImmutableRefTarget<Self, Self::Target>;
    pub fn to_nonnull(self) -> NonNull<Self::Target> { ... }
pub unsafe fn from_nonnull(from: NonNull<Self::Target>) -> Self { ... }
pub fn to_raw_ptr(self) -> *const Self::Target { ... }
pub unsafe fn from_raw_ptr(from: *const Self::Target) -> Option<Self> { ... } }

Trait for non-owning pointers that are shared-reference-like.

Safety

Implementors must only contain a non-null pointer (*1). Meaning that they must be #[repr(transparent)] wrappers around &/NonNull/impl ImmutableRef.

(*1) They can also contain any amount of zero-sized fields with an alignement of 1.

Associated Types

type Target[src]

The referent of the pointer, what it points to.

Loading content...

Associated Constants

pub const TARGET: ImmutableRefTarget<Self, Self::Target>[src]

A marker type that can be used as a proof that the T type parameter of ImmutableRefTarget<T, U> implements ImmutableRef<Target = U>.

Loading content...

Provided methods

pub fn to_nonnull(self) -> NonNull<Self::Target>[src]

Converts this pointer to a NonNull.

pub unsafe fn from_nonnull(from: NonNull<Self::Target>) -> Self[src]

Constructs this pointer from a NonNull.

Safety

from must be one of these:

  • A pointer from a call to ImmutableRef::to_nonnull or ImmutableRef::to_raw_ptr on an instance of Self, with the same lifetime.

  • Valid to transmute to Self.

pub fn to_raw_ptr(self) -> *const Self::Target[src]

Converts this pointer to a raw pointer.

pub unsafe fn from_raw_ptr(from: *const Self::Target) -> Option<Self>[src]

Constructs this pointer from a raw pointer.

Safety

This has the same safety requirements as from_nonnull

Loading content...

Implementations on Foreign Types

impl<'a, T> ImmutableRef for &'a T[src]

type Target = T

Loading content...

Implementors

impl ImmutableRef for Module_Ref[src]

impl<P> ImmutableRef for PrefixRef<P>[src]

type Target = WithMetadata_<P, P>

Loading content...