Struct memory::VirtualAddress
pub struct VirtualAddress(/* private fields */);
Expand description
A virtual memory address, which is a usize
under the hood.
Implementations§
§impl VirtualAddress
impl VirtualAddress
pub fn new(addr: usize) -> Option<VirtualAddress>
pub fn new(addr: usize) -> Option<VirtualAddress>
Creates a new VirtualAddress
, returning an error if the address is not canonical.
This is useful for checking whether an address is valid before using it.
For example, on x86_64, virtual addresses are canonical
if their upper bits (64:48]
are sign-extended from bit 47,
and physical addresses are canonical if their upper bits (64:52]
are 0.
pub const fn new_canonical(addr: usize) -> VirtualAddress
pub const fn new_canonical(addr: usize) -> VirtualAddress
Creates a new VirtualAddress
that is guaranteed to be canonical.
pub const fn zero() -> VirtualAddress
pub const fn zero() -> VirtualAddress
Creates a new VirtualAddress
with a value 0.
pub const fn page_offset(&self) -> usize
pub const fn page_offset(&self) -> usize
Returns the offset from the 4K page boundary specified by this `VirtualAddress.
For example, for the address 0xFFFF_1578
, this will return 0x578
,
the least significant 12 bits (12:0]
of this VirtualAddress
.
Trait Implementations§
§impl Add<usize> for VirtualAddress
impl Add<usize> for VirtualAddress
§type Output = VirtualAddress
type Output = VirtualAddress
The resulting type after applying the
+
operator.§fn add(self, rhs: usize) -> VirtualAddress
fn add(self, rhs: usize) -> VirtualAddress
Performs the
+
operation. Read more§impl Add<VirtualAddress> for VirtualAddress
impl Add<VirtualAddress> for VirtualAddress
§type Output = VirtualAddress
type Output = VirtualAddress
The resulting type after applying the
+
operator.§fn add(self, rhs: VirtualAddress) -> VirtualAddress
fn add(self, rhs: VirtualAddress) -> VirtualAddress
Performs the
+
operation. Read more§impl AddAssign<usize> for VirtualAddress
impl AddAssign<usize> for VirtualAddress
§fn add_assign(&mut self, rhs: usize)
fn add_assign(&mut self, rhs: usize)
Performs the
+=
operation. Read more§impl AddAssign<VirtualAddress> for VirtualAddress
impl AddAssign<VirtualAddress> for VirtualAddress
§fn add_assign(&mut self, rhs: VirtualAddress)
fn add_assign(&mut self, rhs: VirtualAddress)
Performs the
+=
operation. Read more§impl Binary for VirtualAddress
impl Binary for VirtualAddress
§impl BitAnd<VirtualAddress> for VirtualAddress
impl BitAnd<VirtualAddress> for VirtualAddress
§type Output = VirtualAddress
type Output = VirtualAddress
The resulting type after applying the
&
operator.§fn bitand(self, rhs: VirtualAddress) -> VirtualAddress
fn bitand(self, rhs: VirtualAddress) -> VirtualAddress
Performs the
&
operation. Read more§impl BitAndAssign<VirtualAddress> for VirtualAddress
impl BitAndAssign<VirtualAddress> for VirtualAddress
§fn bitand_assign(&mut self, rhs: VirtualAddress)
fn bitand_assign(&mut self, rhs: VirtualAddress)
Performs the
&=
operation. Read more§impl BitOr<VirtualAddress> for VirtualAddress
impl BitOr<VirtualAddress> for VirtualAddress
§type Output = VirtualAddress
type Output = VirtualAddress
The resulting type after applying the
|
operator.§fn bitor(self, rhs: VirtualAddress) -> VirtualAddress
fn bitor(self, rhs: VirtualAddress) -> VirtualAddress
Performs the
|
operation. Read more§impl BitOrAssign<VirtualAddress> for VirtualAddress
impl BitOrAssign<VirtualAddress> for VirtualAddress
§fn bitor_assign(&mut self, rhs: VirtualAddress)
fn bitor_assign(&mut self, rhs: VirtualAddress)
Performs the
|=
operation. Read more§impl BitXor<VirtualAddress> for VirtualAddress
impl BitXor<VirtualAddress> for VirtualAddress
§type Output = VirtualAddress
type Output = VirtualAddress
The resulting type after applying the
^
operator.§fn bitxor(self, rhs: VirtualAddress) -> VirtualAddress
fn bitxor(self, rhs: VirtualAddress) -> VirtualAddress
Performs the
^
operation. Read more§impl BitXorAssign<VirtualAddress> for VirtualAddress
impl BitXorAssign<VirtualAddress> for VirtualAddress
§fn bitxor_assign(&mut self, rhs: VirtualAddress)
fn bitxor_assign(&mut self, rhs: VirtualAddress)
Performs the
^=
operation. Read more§impl Clone for VirtualAddress
impl Clone for VirtualAddress
§fn clone(&self) -> VirtualAddress
fn clone(&self) -> VirtualAddress
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl Debug for VirtualAddress
impl Debug for VirtualAddress
§impl Default for VirtualAddress
impl Default for VirtualAddress
§fn default() -> VirtualAddress
fn default() -> VirtualAddress
Returns the “default value” for a type. Read more
§impl Display for VirtualAddress
impl Display for VirtualAddress
§impl Hash for VirtualAddress
impl Hash for VirtualAddress
§impl Into<usize> for VirtualAddress
impl Into<usize> for VirtualAddress
§impl LowerHex for VirtualAddress
impl LowerHex for VirtualAddress
§impl Octal for VirtualAddress
impl Octal for VirtualAddress
§impl Ord for VirtualAddress
impl Ord for VirtualAddress
§impl PartialEq<VirtualAddress> for VirtualAddress
impl PartialEq<VirtualAddress> for VirtualAddress
§fn eq(&self, other: &VirtualAddress) -> bool
fn eq(&self, other: &VirtualAddress) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.§impl PartialOrd<VirtualAddress> for VirtualAddress
impl PartialOrd<VirtualAddress> for VirtualAddress
§fn partial_cmp(&self, other: &VirtualAddress) -> Option<Ordering>
fn partial_cmp(&self, other: &VirtualAddress) -> Option<Ordering>
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 more§impl Pointer for VirtualAddress
impl Pointer for VirtualAddress
§impl Sub<usize> for VirtualAddress
impl Sub<usize> for VirtualAddress
§type Output = VirtualAddress
type Output = VirtualAddress
The resulting type after applying the
-
operator.§fn sub(self, rhs: usize) -> VirtualAddress
fn sub(self, rhs: usize) -> VirtualAddress
Performs the
-
operation. Read more§impl Sub<VirtualAddress> for VirtualAddress
impl Sub<VirtualAddress> for VirtualAddress
§type Output = VirtualAddress
type Output = VirtualAddress
The resulting type after applying the
-
operator.§fn sub(self, rhs: VirtualAddress) -> VirtualAddress
fn sub(self, rhs: VirtualAddress) -> VirtualAddress
Performs the
-
operation. Read more§impl SubAssign<usize> for VirtualAddress
impl SubAssign<usize> for VirtualAddress
§fn sub_assign(&mut self, rhs: usize)
fn sub_assign(&mut self, rhs: usize)
Performs the
-=
operation. Read more§impl SubAssign<VirtualAddress> for VirtualAddress
impl SubAssign<VirtualAddress> for VirtualAddress
§fn sub_assign(&mut self, rhs: VirtualAddress)
fn sub_assign(&mut self, rhs: VirtualAddress)
Performs the
-=
operation. Read more§impl UpperHex for VirtualAddress
impl UpperHex for VirtualAddress
impl Copy for VirtualAddress
impl Eq for VirtualAddress
impl FromBytes for VirtualAddress
impl StructuralEq for VirtualAddress
impl StructuralPartialEq for VirtualAddress
Auto Trait Implementations§
impl RefUnwindSafe for VirtualAddress
impl Send for VirtualAddress
impl Sync for VirtualAddress
impl Unpin for VirtualAddress
impl UnwindSafe for VirtualAddress
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