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

§

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

§

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

§

type Output = MemoryRegionAddress

The resulting type after applying the | operator.
source§

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

Performs the | operation. Read more
source§

impl<B: Bitmap> Bytes<MemoryRegionAddress> for GuestRegionMmap<B>

source§

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

§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>

§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§

fn read_from<F>( &self, addr: MemoryRegionAddress, src: &mut F, count: usize ) -> Result<usize>
where F: Read,

👎Deprecated: Use .read_volatile_from or the functions of the ReadVolatile trait instead
§Examples
  • Read bytes from /dev/urandom
let mut file = File::open(Path::new("/dev/urandom")).expect("Could not open /dev/urandom");

gm.read_from(addr, &mut file, 128)
    .expect("Could not read from /dev/urandom into guest memory");

let read_addr = addr.checked_add(8).expect("Could not compute read address");
let rand_val: u32 = gm
    .read_obj(read_addr)
    .expect("Could not read u32 val from /dev/urandom");
source§

fn read_exact_from<F>( &self, addr: MemoryRegionAddress, src: &mut F, count: usize ) -> Result<()>
where F: Read,

👎Deprecated: Use .read_exact_volatile_from or the functions of the ReadVolatile trait instead
§Examples
  • Read bytes from /dev/urandom
let mut file = File::open(Path::new("/dev/urandom")).expect("Could not open /dev/urandom");

gm.read_exact_from(addr, &mut file, 128)
    .expect("Could not read from /dev/urandom into guest memory");

let read_addr = addr.checked_add(8).expect("Could not compute read address");
let rand_val: u32 = gm
    .read_obj(read_addr)
    .expect("Could not read u32 val from /dev/urandom");
source§

fn write_to<F>( &self, addr: MemoryRegionAddress, dst: &mut F, count: usize ) -> Result<usize>
where F: Write,

👎Deprecated: Use .write_volatile_to or the functions of the WriteVolatile trait instead

Writes data from the region to a writable object.

§Examples
  • Write 128 bytes to a /dev/null file
let mut file = OpenOptions::new()
    .write(true)
    .open("/dev/null")
    .expect("Could not open /dev/null");

gm.write_to(start_addr, &mut file, 128)
    .expect("Could not write to file from guest memory");
source§

fn write_all_to<F>( &self, addr: MemoryRegionAddress, dst: &mut F, count: usize ) -> Result<()>
where F: Write,

👎Deprecated: Use .write_all_volatile_to or the functions of the WriteVolatile trait instead

Writes data from the region to a writable object.

§Examples
  • Write 128 bytes to a /dev/null file
let mut file = OpenOptions::new()
    .write(true)
    .open("/dev/null")
    .expect("Could not open /dev/null");

gm.write_all_to(start_addr, &mut file, 128)
    .expect("Could not write to file from guest memory");
§

type E = Error

Associated error codes
source§

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

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<()>

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

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

Atomically store a value at the specified address.
source§

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

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 Clone for MemoryRegionAddress

source§

fn clone(&self) -> MemoryRegionAddress

Returns a copy 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 + PartialOrd,

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

impl PartialEq for MemoryRegionAddress

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method 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

This method 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

This method 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

This method 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<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,

§

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>,

§

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>,

§

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.