pub struct MemoryRegionAddress(pub u64);
Expand description
Represents an offset inside a region.
Tuple Fields§
§0: u64
Trait Implementations§
Source§impl Address for MemoryRegionAddress
impl Address for MemoryRegionAddress
Source§fn new(value: u64) -> MemoryRegionAddress
fn new(value: u64) -> MemoryRegionAddress
Creates an address from a raw address value.
Source§fn checked_offset_from(&self, base: MemoryRegionAddress) -> Option<u64>
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>
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)
fn overflowing_add(&self, other: u64) -> (MemoryRegionAddress, bool)
Computes
self + other
. Read moreSource§fn unchecked_add(&self, offset: u64) -> MemoryRegionAddress
fn unchecked_add(&self, offset: u64) -> MemoryRegionAddress
Computes
self + offset
. Read moreSource§fn checked_sub(&self, other: u64) -> Option<MemoryRegionAddress>
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)
fn overflowing_sub(&self, other: u64) -> (MemoryRegionAddress, bool)
Computes
self - other
. Read moreSource§fn unchecked_sub(&self, other: u64) -> MemoryRegionAddress
fn unchecked_sub(&self, other: u64) -> MemoryRegionAddress
Computes
self - other
. Read moreSource§fn mask(&self, mask: Self::V) -> Self::V
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
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>
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
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
impl AddressValue for MemoryRegionAddress
Source§impl BitAnd<u64> for MemoryRegionAddress
impl BitAnd<u64> for MemoryRegionAddress
Source§type Output = MemoryRegionAddress
type Output = MemoryRegionAddress
The resulting type after applying the
&
operator.Source§impl BitOr<u64> for MemoryRegionAddress
impl BitOr<u64> for MemoryRegionAddress
Source§type Output = MemoryRegionAddress
type Output = MemoryRegionAddress
The resulting type after applying the
|
operator.Source§impl Clone for MemoryRegionAddress
impl Clone for MemoryRegionAddress
Source§fn clone(&self) -> MemoryRegionAddress
fn clone(&self) -> MemoryRegionAddress
Returns a duplicate 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 MemoryRegionAddress
impl Debug for MemoryRegionAddress
Source§impl Default for MemoryRegionAddress
impl Default for MemoryRegionAddress
Source§fn default() -> MemoryRegionAddress
fn default() -> MemoryRegionAddress
Returns the “default value” for a type. Read more
Source§impl Ord for MemoryRegionAddress
impl Ord for MemoryRegionAddress
Source§fn cmp(&self, other: &MemoryRegionAddress) -> Ordering
fn cmp(&self, other: &MemoryRegionAddress) -> 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 MemoryRegionAddress
impl PartialEq for MemoryRegionAddress
Source§impl PartialOrd for MemoryRegionAddress
impl PartialOrd for MemoryRegionAddress
impl Copy for MemoryRegionAddress
impl Eq for MemoryRegionAddress
impl StructuralPartialEq for MemoryRegionAddress
Auto Trait Implementations§
impl Freeze for MemoryRegionAddress
impl RefUnwindSafe for MemoryRegionAddress
impl Send for MemoryRegionAddress
impl Sync for MemoryRegionAddress
impl Unpin for MemoryRegionAddress
impl UnwindSafe for MemoryRegionAddress
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
Source§impl<R> Bytes<MemoryRegionAddress> for Rwhere
R: GuestMemoryRegionBytes,
impl<R> Bytes<MemoryRegionAddress> for Rwhere
R: GuestMemoryRegionBytes,
Source§fn write(&self, buf: &[u8], addr: MemoryRegionAddress) -> Result<usize, Error>
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>
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§fn write_slice(
&self,
buf: &[u8],
addr: MemoryRegionAddress,
) -> Result<(), Error>
fn write_slice( &self, buf: &[u8], addr: MemoryRegionAddress, ) -> Result<(), Error>
Writes the entire content of a slice into the container at
addr
. Read moreSource§fn read_slice(
&self,
buf: &mut [u8],
addr: MemoryRegionAddress,
) -> Result<(), Error>
fn read_slice( &self, buf: &mut [u8], addr: MemoryRegionAddress, ) -> Result<(), Error>
Reads data from the container at
addr
to fill an entire slice. Read moreSource§fn read_volatile_from<F>(
&self,
addr: MemoryRegionAddress,
src: &mut F,
count: usize,
) -> Result<usize, Error>where
F: ReadVolatile,
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 moreSource§fn read_exact_volatile_from<F>(
&self,
addr: MemoryRegionAddress,
src: &mut F,
count: usize,
) -> Result<(), Error>where
F: ReadVolatile,
fn read_exact_volatile_from<F>(
&self,
addr: MemoryRegionAddress,
src: &mut F,
count: usize,
) -> Result<(), Error>where
F: ReadVolatile,
Source§fn write_volatile_to<F>(
&self,
addr: MemoryRegionAddress,
dst: &mut F,
count: usize,
) -> Result<usize, Error>where
F: WriteVolatile,
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 moreSource§fn write_all_volatile_to<F>(
&self,
addr: MemoryRegionAddress,
dst: &mut F,
count: usize,
) -> Result<(), Error>where
F: WriteVolatile,
fn write_all_volatile_to<F>(
&self,
addr: MemoryRegionAddress,
dst: &mut F,
count: usize,
) -> Result<(), Error>where
F: WriteVolatile,
Source§fn store<T>(
&self,
val: T,
addr: MemoryRegionAddress,
order: Ordering,
) -> Result<(), Error>where
T: AtomicAccess,
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,
fn load<T>(
&self,
addr: MemoryRegionAddress,
order: Ordering,
) -> Result<T, Error>where
T: AtomicAccess,
Atomically load a value from the specified address.