Struct vm_memory::guest_address::GuestAddress
source · pub struct GuestAddress(pub u64);
Expand description
Represents an Address in the guest’s memory.
Tuple Fields§
§0: u64
Implementations§
source§impl GuestAddress
impl GuestAddress
sourcepub fn offset_from(self, base: GuestAddress) -> u64
pub fn offset_from(self, base: GuestAddress) -> u64
Returns the offset from this address to the given base address.
§Examples
let base = GuestAddress(0x100);
let addr = GuestAddress(0x150);
assert_eq!(addr.offset_from(base), 0x50u64);
sourcepub fn offset(self) -> u64
pub fn offset(self) -> u64
Returns the address as a u64 offset from 0x0. Use this when a raw number is needed to pass to the kernel.
sourcepub fn checked_add(self, other: u64) -> Option<GuestAddress>
pub fn checked_add(self, other: u64) -> Option<GuestAddress>
Returns the result of the add or None if there is overflow.
sourcepub fn unchecked_add(self, offset: u64) -> GuestAddress
pub fn unchecked_add(self, offset: u64) -> GuestAddress
Returns the result of the base address + the size.
Only use this when offset
is guaranteed not to overflow.
sourcepub fn checked_sub(self, other: u64) -> Option<GuestAddress>
pub fn checked_sub(self, other: u64) -> Option<GuestAddress>
Returns the result of the subtraction of None if there is underflow.
sourcepub fn mask(self, mask: u64) -> GuestAddress
pub fn mask(self, mask: u64) -> GuestAddress
Returns the bitwise and of the address with the given mask.
sourcepub fn align(self, align: u64) -> Option<GuestAddress>
pub fn align(self, align: u64) -> Option<GuestAddress>
Returns the next highest address that is a multiple of align
, or an unchanged copy of the
address if it’s already a multiple of align
. Returns None on overflow.
align
must be a power of 2.
sourcepub fn align_down(self, align: u64) -> GuestAddress
pub fn align_down(self, align: u64) -> GuestAddress
Returns the next lowest address that is a multiple of align
, or an unchanged copy of the
address if it’s already a multiple of align
.
align
must be a power of 2.
Trait Implementations§
source§impl BitAnd<u64> for GuestAddress
impl BitAnd<u64> for GuestAddress
§type Output = GuestAddress
type Output = GuestAddress
&
operator.source§impl BitOr<u64> for GuestAddress
impl BitOr<u64> for GuestAddress
§type Output = GuestAddress
type Output = GuestAddress
|
operator.source§impl Clone for GuestAddress
impl Clone for GuestAddress
source§fn clone(&self) -> GuestAddress
fn clone(&self) -> GuestAddress
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for GuestAddress
impl Debug for GuestAddress
source§impl<'de> Deserialize<'de> for GuestAddress
impl<'de> Deserialize<'de> for GuestAddress
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Display for GuestAddress
impl Display for GuestAddress
source§impl Ord for GuestAddress
impl Ord for GuestAddress
source§fn cmp(&self, other: &GuestAddress) -> Ordering
fn cmp(&self, other: &GuestAddress) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for GuestAddress
impl PartialEq for GuestAddress
source§fn eq(&self, other: &GuestAddress) -> bool
fn eq(&self, other: &GuestAddress) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for GuestAddress
impl PartialOrd for GuestAddress
source§fn partial_cmp(&self, other: &GuestAddress) -> Option<Ordering>
fn partial_cmp(&self, other: &GuestAddress) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for GuestAddress
impl Serialize for GuestAddress
impl Copy for GuestAddress
impl Eq for GuestAddress
Auto Trait Implementations§
impl Freeze for GuestAddress
impl RefUnwindSafe for GuestAddress
impl Send for GuestAddress
impl Sync for GuestAddress
impl Unpin for GuestAddress
impl UnwindSafe for GuestAddress
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: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)