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

pub unsafe trait ImmutableRef: Copy {
    type Target;

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

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

The referent of the pointer, what it points to.

Associated Constants

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

Provided methods

Converts this pointer to a NonNull.

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.

Converts this pointer to a raw pointer.

Constructs this pointer from a raw pointer.

Safety

This has the same safety requirements as from_nonnull

Implementations on Foreign Types

Implementors