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 be #[repr(transparent)] wrappers around &/NonNull/impl ImmutableRef, with any amount of 1-aligned zero-sized fields.

It must be valid to transmute a NonNull<Self::Target> pointer obtained from Self::to_nonnull back into Self, producing a pointer just as usable as the original.

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 a pointer from a call to ImmutableRef::to_nonnull or ImmutableRef::to_raw_ptr on an instance of 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