pub trait Strict: Sealed {
type Pointee;
fn addr(self) -> usize
where
Self::Pointee: Sized;
fn with_addr(self, addr: usize) -> Self
where
Self::Pointee: Sized;
fn map_addr(self, f: impl FnOnce(usize) -> usize) -> Self
where
Self::Pointee: Sized;
fn to_bits(self) -> usize
where
Self::Pointee: Sized;
fn from_bits(bits: usize) -> Self
where
Self::Pointee: Sized;
}
Associated Types
Required methods
Gets the “address” portion of the pointer.
This is equivalent to self as usize
, which semantically discards
provenance and address-space information. To properly restore that information,
use with_addr
or map_addr
.
On most platforms this will produce a value with the same bytes as the original pointer, because all the bytes are dedicated to describing the address. Platforms which need to store additional information in the pointer may perform a change of representation to produce a value containing only the address portion of the pointer. What that means is up to the platform to define.
This API and its claimed semantics are part of the Strict Provenance experiment, see the module documentation for details.
Creates a new pointer with the given address.
This performs the same operation as an addr as ptr
cast, but copies
the address-space and provenance of self
to the new pointer.
This allows us to dynamically preserve and propagate this important
information in a way that is otherwise impossible with a unary cast.
This is equivalent to using wrapping_offset
to offset
self
to the given address, and therefore has all the same capabilities and restrictions.
This API and its claimed semantics are part of the Strict Provenance experiment, see the module documentation for details.
Creates a new pointer by mapping self
’s address to a new one.
This is a convenience for with_addr
, see that method for details.
This API and its claimed semantics are part of the Strict Provenance experiment, see the module documentation for details.
to_bits is incompatible with strict_provenance