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.
Trait Implementations§
Source§impl BitAnd<u64> for GuestAddress
impl BitAnd<u64> for GuestAddress
Source§type Output = GuestAddress
type Output = GuestAddress
The resulting type after applying the
&
operator.Source§impl BitOr<u64> for GuestAddress
impl BitOr<u64> for GuestAddress
Source§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 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 for GuestAddress
impl PartialEq for GuestAddress
Source§impl PartialOrd for GuestAddress
impl PartialOrd 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
Mutably borrows from an owned value. Read more