pub struct Address<M, T>where
M: Mutability,
T: ?Sized,{ /* private fields */ }
Expand description
A generic non-null pointer with type-system mutability tracking.
§Type Parameters
M
: The mutability permissions of the source pointer.T
: The referent type of the source pointer.
Implementations§
Source§impl<M, T> Address<M, T>where
M: Mutability,
impl<M, T> Address<M, T>where
M: Mutability,
Source§impl<M, T> Address<M, T>where
M: Mutability,
T: ?Sized,
impl<M, T> Address<M, T>where
M: Mutability,
T: ?Sized,
Sourcepub fn new(addr: NonNull<T>) -> Self
pub fn new(addr: NonNull<T>) -> Self
Constructs a new Address
over some pointer value.
You are responsible for selecting the correct Mutability
marker.
Sourcepub fn immut(self) -> Address<Const, T>
pub fn immut(self) -> Address<Const, T>
Permanently converts an Address<_>
into an Address<Const>
.
You should generally prefer Address::freeze
.
Sourcepub unsafe fn assert_mut(self) -> Address<Mut, T>
pub unsafe fn assert_mut(self) -> Address<Mut, T>
Force an Address<Const>
to be Address<Mut>
.
§Safety
You should only call this on addresses you know to have been created
with Mut
able permissions and previously removed by Address::immut
.
You should prefer using Address::freeze
for temporary, trackable,
immutability constraints instead.
Sourcepub fn into_inner(self) -> NonNull<T>
pub fn into_inner(self) -> NonNull<T>
Removes the Address
type marker, returning the original pointer.
Source§impl<M, T> Address<M, T>where
M: Mutability,
impl<M, T> Address<M, T>where
M: Mutability,
Port of the pointer inherent methods on Address
es of Sized
types.
Sourcepub fn wrapping_offset(self, count: isize) -> Self
pub fn wrapping_offset(self, count: isize) -> Self
Applies <*T>::wrapping_offset
.
Sourcepub fn wrapping_add(self, count: usize) -> Self
pub fn wrapping_add(self, count: usize) -> Self
Applies <*T>::wrapping_add
.
Sourcepub fn wrapping_sub(self, count: usize) -> Self
pub fn wrapping_sub(self, count: usize) -> Self
Applies <*T>::wrapping_sub
.
Sourcepub unsafe fn offset_from(self, origin: Self) -> isize
pub unsafe fn offset_from(self, origin: Self) -> isize
Applies <*T>::offset_from
.
Sourcepub unsafe fn read_volatile(self) -> T
pub unsafe fn read_volatile(self) -> T
Applies <*T>::read_volatile
.
Sourcepub unsafe fn read_unaligned(self) -> T
pub unsafe fn read_unaligned(self) -> T
Applies <*T>::read_unaligned
.
Sourcepub unsafe fn copy_to_nonoverlapping(self, dest: Address<Mut, T>, count: usize)
pub unsafe fn copy_to_nonoverlapping(self, dest: Address<Mut, T>, count: usize)
Applies <*T>::copy_to_nonoverlapping
.
Sourcepub fn align_offset(self, align: usize) -> usize
pub fn align_offset(self, align: usize) -> usize
Applies <*T>::align_offset
.
Source§impl<M, T> Address<M, T>where
M: Mutability,
T: ?Sized,
impl<M, T> Address<M, T>where
M: Mutability,
T: ?Sized,
Port of the pointer inherent methods on Address
es of any type.
Source§impl<T> Address<Mut, T>
impl<T> Address<Mut, T>
Port of pointer inherent methods on mutable Address
es of sized types.
Sourcepub unsafe fn copy_from<M2: Mutability>(self, src: Address<M2, T>, count: usize)
pub unsafe fn copy_from<M2: Mutability>(self, src: Address<M2, T>, count: usize)
Applies <*T>::copy_from
.
Sourcepub unsafe fn copy_from_nonoverlapping<M2: Mutability>(
self,
src: Address<M2, T>,
count: usize,
)
pub unsafe fn copy_from_nonoverlapping<M2: Mutability>( self, src: Address<M2, T>, count: usize, )
Applies <*T>::copy_from_nonoverlapping
.
Sourcepub unsafe fn write_volatile(self, value: T)
pub unsafe fn write_volatile(self, value: T)
Applies <*T>::write_volatile
.
Sourcepub unsafe fn write_unaligned(self, value: T)
pub unsafe fn write_unaligned(self, value: T)
Applies <*T>::write_unaligned
.
Trait Implementations§
Source§impl<M, T> Ord for Address<M, T>where
M: Mutability,
impl<M, T> Ord for Address<M, T>where
M: Mutability,
Source§impl<M1, M2, T1, T2> PartialEq<Address<M2, T2>> for Address<M1, T1>where
M1: Mutability,
M2: Mutability,
impl<M1, M2, T1, T2> PartialEq<Address<M2, T2>> for Address<M1, T1>where
M1: Mutability,
M2: Mutability,
Source§impl<M1, M2, T1, T2> PartialOrd<Address<M2, T2>> for Address<M1, T1>where
M1: Mutability,
M2: Mutability,
impl<M1, M2, T1, T2> PartialOrd<Address<M2, T2>> for Address<M1, T1>where
M1: Mutability,
M2: Mutability,
Source§impl<'a, M, T> Referential<'a> for Address<Frozen<M>, T>where
M: Mutability,
T: 'a + ?Sized,
impl<'a, M, T> Referential<'a> for Address<Frozen<M>, T>where
M: Mutability,
T: 'a + ?Sized,
Source§impl<'a, T> SliceReferential<'a> for Address<Const, [T]>where
T: 'a,
impl<'a, T> SliceReferential<'a> for Address<Const, [T]>where
T: 'a,
Source§type ElementAddr = Address<Const, T>
type ElementAddr = Address<Const, T>
Source§unsafe fn from_raw_parts(ptr: Self::ElementAddr, len: usize) -> Self::Ref
unsafe fn from_raw_parts(ptr: Self::ElementAddr, len: usize) -> Self::Ref
Source§impl<'a, M, T> SliceReferential<'a> for Address<Frozen<M>, [T]>where
M: Mutability,
T: 'a,
impl<'a, M, T> SliceReferential<'a> for Address<Frozen<M>, [T]>where
M: Mutability,
T: 'a,
Source§type ElementAddr = Address<Frozen<M>, T>
type ElementAddr = Address<Frozen<M>, T>
Source§unsafe fn from_raw_parts(ptr: Self::ElementAddr, len: usize) -> Self::Ref
unsafe fn from_raw_parts(ptr: Self::ElementAddr, len: usize) -> Self::Ref
Source§impl<'a, T> SliceReferential<'a> for Address<Mut, [T]>where
T: 'a,
impl<'a, T> SliceReferential<'a> for Address<Mut, [T]>where
T: 'a,
Source§type ElementAddr = Address<Mut, T>
type ElementAddr = Address<Mut, T>
Source§unsafe fn from_raw_parts(ptr: Self::ElementAddr, len: usize) -> Self::Ref
unsafe fn from_raw_parts(ptr: Self::ElementAddr, len: usize) -> Self::Ref
impl<M, T> Copy for Address<M, T>where
M: Mutability,
T: ?Sized,
impl<M, T> Eq for Address<M, T>where
M: Mutability,
Auto Trait Implementations§
impl<M, T> Freeze for Address<M, T>
impl<M, T> RefUnwindSafe for Address<M, T>
impl<M, T> !Send for Address<M, T>
impl<M, T> !Sync for Address<M, T>
impl<M, T> Unpin for Address<M, T>
impl<M, T> UnwindSafe for Address<M, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.