pub struct VAddr(/* private fields */);
Implementations§
source§impl VAddr
impl VAddr
pub fn from_usize_checked(u: usize) -> Result<Self, InvalidAddress>
sourcepub const unsafe fn from_usize_unchecked(u: usize) -> Self
pub const unsafe fn from_usize_unchecked(u: usize) -> Self
Constructs a VAddr
from an arbitrary usize
value without checking
if it’s valid.
Pros of this function:
- can be used in const-eval contexts
Cons of this function:
- “refer to ‘Safety’ section”
Safety
u can use dis function to construct invalid addresses. probably dont do that.
pub fn of<T: ?Sized>(pointee: &T) -> Self
source§impl VAddr
impl VAddr
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 VAddr
impl Add<usize> for VAddr
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 VAddr
impl AddAssign<usize> for VAddr
source§fn add_assign(&mut self, rhs: usize)
fn add_assign(&mut self, rhs: usize)
Performs the
+=
operation. Read moresource§impl AddAssign for VAddr
impl AddAssign for VAddr
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresource§impl Address for VAddr
impl Address for VAddr
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 VAddr
impl Ord for VAddr
source§impl PartialEq for VAddr
impl PartialEq for VAddr
source§impl PartialOrd for VAddr
impl PartialOrd for VAddr
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 VAddr
impl SubAssign<usize> for VAddr
source§fn sub_assign(&mut self, rhs: usize)
fn sub_assign(&mut self, rhs: usize)
Performs the
-=
operation. Read moresource§impl SubAssign for VAddr
impl SubAssign for VAddr
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read moreimpl Copy for VAddr
impl Eq for VAddr
impl StructuralEq for VAddr
impl StructuralPartialEq for VAddr
Auto Trait Implementations§
impl RefUnwindSafe for VAddr
impl Send for VAddr
impl Sync for VAddr
impl Unpin for VAddr
impl UnwindSafe for VAddr
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.