pub struct GuestAddress(pub u64);Expand description
Represents an Address in the guest’s memory.
Tuple Fields§
§0: u64Implementations§
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
Source§type Output = GuestAddress
type Output = GuestAddress
& operator.Source§impl BitOr<u64> for GuestAddress
impl BitOr<u64> for GuestAddress
Source§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 more