MemoryRegionAddress

Struct MemoryRegionAddress 

Source
pub struct MemoryRegionAddress(pub u64);
Expand description

Represents an offset inside a region.

Tuple Fields§

§0: u64

Trait Implementations§

Source§

impl Address for MemoryRegionAddress

Source§

fn new(value: u64) -> MemoryRegionAddress

Creates an address from a raw address value.
Source§

fn raw_value(&self) -> u64

Returns the raw value of the address.
Source§

fn checked_offset_from(&self, base: MemoryRegionAddress) -> Option<u64>

Computes the offset from this address to the given base address. Read more
Source§

fn checked_add(&self, other: u64) -> Option<MemoryRegionAddress>

Computes self + other, returning None if overflow occurred.
Source§

fn overflowing_add(&self, other: u64) -> (MemoryRegionAddress, bool)

Computes self + other. Read more
Source§

fn unchecked_add(&self, offset: u64) -> MemoryRegionAddress

Computes self + offset. Read more
Source§

fn checked_sub(&self, other: u64) -> Option<MemoryRegionAddress>

Subtracts two addresses, checking for underflow. If underflow happens, None is returned.
Source§

fn overflowing_sub(&self, other: u64) -> (MemoryRegionAddress, bool)

Computes self - other. Read more
Source§

fn unchecked_sub(&self, other: u64) -> MemoryRegionAddress

Computes self - other. Read more
Source§

fn mask(&self, mask: Self::V) -> Self::V

Returns the bitwise and of the address with the given mask.
Source§

fn unchecked_offset_from(&self, base: Self) -> Self::V

Computes the offset from this address to the given base address. Read more
Source§

fn checked_align_up(&self, power_of_two: Self::V) -> Option<Self>

Returns self, aligned to the given power of two.
Source§

fn unchecked_align_up(&self, power_of_two: Self::V) -> Self

Returns self, aligned to the given power of two. Only use this when the result is guaranteed not to overflow.
Source§

impl AddressValue for MemoryRegionAddress

Source§

type V = u64

Type of the raw address value.
Source§

fn zero() -> Self::V

Return the value zero, coerced into the value type Self::V
Source§

fn one() -> Self::V

Return the value zero, coerced into the value type Self::V
Source§

impl BitAnd<u64> for MemoryRegionAddress

Source§

type Output = MemoryRegionAddress

The resulting type after applying the & operator.
Source§

fn bitand(self, other: u64) -> MemoryRegionAddress

Performs the & operation. Read more
Source§

impl BitOr<u64> for MemoryRegionAddress

Source§

type Output = MemoryRegionAddress

The resulting type after applying the | operator.
Source§

fn bitor(self, other: u64) -> MemoryRegionAddress

Performs the | operation. Read more
Source§

impl Clone for MemoryRegionAddress

Source§

fn clone(&self) -> MemoryRegionAddress

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryRegionAddress

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MemoryRegionAddress

Source§

fn default() -> MemoryRegionAddress

Returns the “default value” for a type. Read more
Source§

impl Ord for MemoryRegionAddress

Source§

fn cmp(&self, other: &MemoryRegionAddress) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for MemoryRegionAddress

Source§

fn eq(&self, other: &MemoryRegionAddress) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for MemoryRegionAddress

Source§

fn partial_cmp(&self, other: &MemoryRegionAddress) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for MemoryRegionAddress

Source§

impl Eq for MemoryRegionAddress

Source§

impl StructuralPartialEq for MemoryRegionAddress

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<R> Bytes<MemoryRegionAddress> for R

Source§

fn write(&self, buf: &[u8], addr: MemoryRegionAddress) -> Result<usize, Error>

§Examples
  • Write a slice at guest address 0x1200.
let res = gm
    .write(&[1, 2, 3, 4, 5], GuestAddress(0x1200))
    .expect("Could not write to guest memory");
assert_eq!(5, res);
Source§

fn read( &self, buf: &mut [u8], addr: MemoryRegionAddress, ) -> Result<usize, Error>

§Examples
  • Read a slice of length 16 at guestaddress 0x1200.
let buf = &mut [0u8; 16];
let res = gm
    .read(buf, GuestAddress(0x1200))
    .expect("Could not read from guest memory");
assert_eq!(16, res);
Source§

type E = Error

Associated error codes
Source§

fn write_slice( &self, buf: &[u8], addr: MemoryRegionAddress, ) -> Result<(), Error>

Writes the entire content of a slice into the container at addr. Read more
Source§

fn read_slice( &self, buf: &mut [u8], addr: MemoryRegionAddress, ) -> Result<(), Error>

Reads data from the container at addr to fill an entire slice. Read more
Source§

fn read_volatile_from<F>( &self, addr: MemoryRegionAddress, src: &mut F, count: usize, ) -> Result<usize, Error>
where F: ReadVolatile,

Reads up to count bytes from src and writes them into the container at addr. Unlike VolatileRead::read_volatile, this function retries on EINTR being returned from the underlying I/O read operation. Read more
Source§

fn read_exact_volatile_from<F>( &self, addr: MemoryRegionAddress, src: &mut F, count: usize, ) -> Result<(), Error>
where F: ReadVolatile,

Reads exactly count bytes from an object and writes them into the container at addr. Read more
Source§

fn write_volatile_to<F>( &self, addr: MemoryRegionAddress, dst: &mut F, count: usize, ) -> Result<usize, Error>
where F: WriteVolatile,

Reads up to count bytes from the container at addr and writes them into dst. Unlike VolatileWrite::write_volatile, this function retries on EINTR being returned by the underlying I/O write operation. Read more
Source§

fn write_all_volatile_to<F>( &self, addr: MemoryRegionAddress, dst: &mut F, count: usize, ) -> Result<(), Error>
where F: WriteVolatile,

Reads exactly count bytes from the container at addr and writes them into an object. Read more
Source§

fn store<T>( &self, val: T, addr: MemoryRegionAddress, order: Ordering, ) -> Result<(), Error>
where T: AtomicAccess,

Atomically store a value at the specified address.
Source§

fn load<T>( &self, addr: MemoryRegionAddress, order: Ordering, ) -> Result<T, Error>
where T: AtomicAccess,

Atomically load a value from the specified address.
Source§

fn write_obj<T: ByteValued>(&self, val: T, addr: A) -> Result<(), Self::E>

Writes an object into the container at addr. Read more
Source§

fn read_obj<T: ByteValued>(&self, addr: A) -> Result<T, Self::E>

Reads an object from the container at addr. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.