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.
Trait Implementations§
source§impl BitAnd<u64> for GuestAddress
impl BitAnd<u64> for GuestAddress
§type Output = GuestAddress
type Output = GuestAddress
The resulting type after applying the
&
operator.source§impl BitOr<u64> for GuestAddress
impl BitOr<u64> for GuestAddress
§type Output = GuestAddress
type Output = GuestAddress
The resulting type after applying the
|
operator.source§impl Clone for GuestAddress
impl Clone for GuestAddress
source§fn clone(&self) -> GuestAddress
fn clone(&self) -> GuestAddress
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 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>,
Deserialize this value from the given Serde deserializer. Read more
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,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<GuestAddress> for GuestAddress
impl PartialEq<GuestAddress> for GuestAddress
source§fn eq(&self, other: &GuestAddress) -> bool
fn eq(&self, other: &GuestAddress) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<GuestAddress> for GuestAddress
impl PartialOrd<GuestAddress> 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
This method tests less than or equal to (for
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 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
Mutably borrows from an owned value. Read more