pub struct PAddr(/* private fields */);
Implementations§
source§impl PAddr
impl PAddr
pub fn from_usize_checked(u: usize) -> Result<Self, InvalidAddress>
source§impl PAddr
impl PAddr
pub const fn zero() -> Self
sourcepub fn from_u64(u: u64) -> Self
pub fn from_u64(u: u64) -> Self
Panics
- If debug assertions are enabled and the address is not valid for the target architecture.
sourcepub fn align_up<A: Into<usize>>(self, align: A) -> Self
pub fn align_up<A: Into<usize>>(self, align: A) -> Self
Aligns self
up to align
.
The specified alignment must be a power of two.
Panics
- If
align
is not a power of two. - If debug assertions are enabled and the aligned address is not valid for the target architecture.
sourcepub fn align_down<A: Into<usize>>(self, align: A) -> Self
pub fn align_down<A: Into<usize>>(self, align: A) -> Self
Aligns self
down to align
.
The specified alignment must be a power of two.
Panics
- If
align
is not a power of two. - If debug assertions are enabled and the aligned address is not valid for the target architecture.
sourcepub fn offset(self, offset: i32) -> Self
pub fn offset(self, offset: i32) -> Self
Offsets this address by offset
.
If the specified offset would overflow, this function saturates instead.
sourcepub fn difference(self, other: Self) -> isize
pub fn difference(self, other: Self) -> isize
Returns the difference between self
and other
.
sourcepub fn is_aligned<A: Into<usize>>(self, align: A) -> bool
pub fn is_aligned<A: Into<usize>>(self, align: A) -> bool
Returns true
if self
is aligned on the specified alignment.
sourcepub fn is_aligned_for<T>(self) -> bool
pub fn is_aligned_for<T>(self) -> bool
Returns true
if self
is aligned on the alignment of the specified
type.
Trait Implementations§
source§impl Add<usize> for PAddr
impl Add<usize> for PAddr
source§fn add(self, rhs: usize) -> Self
fn add(self, rhs: usize) -> Self
Offset self
up by rhs
.
Notes
- The address will be offset by the minimum addressable unit
of the target architecture (i.e. probably bytes), not by
by units of a Rust type like
{*const T, *mut T}::add
. - Therefore, resulting address may have a different alignment from the input address.
Panics
- If the resulting address is invalid.
source§impl AddAssign<usize> for PAddr
impl AddAssign<usize> for PAddr
source§fn add_assign(&mut self, rhs: usize)
fn add_assign(&mut self, rhs: usize)
Performs the
+=
operation. Read moresource§impl AddAssign for PAddr
impl AddAssign for PAddr
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresource§impl Address for PAddr
impl Address for PAddr
source§fn from_usize(u: usize) -> Self
fn from_usize(u: usize) -> Self
Panics
- If debug assertions are enabled and the address is not valid for the target architecture.
fn as_usize(self) -> usize
source§fn align_up_for<T>(self) -> Self
fn align_up_for<T>(self) -> Self
source§fn align_down_for<T>(self) -> Self
fn align_down_for<T>(self) -> Self
source§fn difference(self, other: Self) -> isize
fn difference(self, other: Self) -> isize
Returns the difference between
self
and other
.source§fn is_aligned_for<T>(self) -> bool
fn is_aligned_for<T>(self) -> bool
Returns
true
if self
is aligned on the alignment of the specified
type.source§impl Ord for PAddr
impl Ord for PAddr
source§impl PartialEq for PAddr
impl PartialEq for PAddr
source§impl PartialOrd for PAddr
impl PartialOrd for PAddr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl SubAssign<usize> for PAddr
impl SubAssign<usize> for PAddr
source§fn sub_assign(&mut self, rhs: usize)
fn sub_assign(&mut self, rhs: usize)
Performs the
-=
operation. Read moresource§impl SubAssign for PAddr
impl SubAssign for PAddr
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read moreimpl Copy for PAddr
impl Eq for PAddr
impl StructuralEq for PAddr
impl StructuralPartialEq for PAddr
Auto Trait Implementations§
impl RefUnwindSafe for PAddr
impl Send for PAddr
impl Sync for PAddr
impl Unpin for PAddr
impl UnwindSafe for PAddr
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
Mutably borrows from an owned value. Read more
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.