Trait vm_memory::volatile_memory::VolatileMemory

source ·
pub trait VolatileMemory {
    type B: Bitmap;

    // Required methods
    fn len(&self) -> usize;
    fn get_slice(
        &self,
        offset: usize,
        count: usize,
    ) -> Result<VolatileSlice<'_, BS<'_, Self::B>>>;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn as_volatile_slice(&self) -> VolatileSlice<'_, BS<'_, Self::B>> { ... }
    fn get_ref<T: ByteValued>(
        &self,
        offset: usize,
    ) -> Result<VolatileRef<'_, T, BS<'_, Self::B>>> { ... }
    fn get_array_ref<T: ByteValued>(
        &self,
        offset: usize,
        n: usize,
    ) -> Result<VolatileArrayRef<'_, T, BS<'_, Self::B>>> { ... }
    unsafe fn aligned_as_ref<T: ByteValued>(&self, offset: usize) -> Result<&T> { ... }
    unsafe fn aligned_as_mut<T: ByteValued>(
        &self,
        offset: usize,
    ) -> Result<&mut T> { ... }
    fn get_atomic_ref<T: AtomicInteger>(&self, offset: usize) -> Result<&T> { ... }
    fn compute_end_offset(&self, base: usize, offset: usize) -> Result<usize> { ... }
}
Expand description

Types that support raw volatile access to their data.

Required Associated Types§

source

type B: Bitmap

Type used for dirty memory tracking.

Required Methods§

source

fn len(&self) -> usize

Gets the size of this slice.

source

fn get_slice( &self, offset: usize, count: usize, ) -> Result<VolatileSlice<'_, BS<'_, Self::B>>>

Returns a VolatileSlice of count bytes starting at offset.

Provided Methods§

source

fn is_empty(&self) -> bool

Check whether the region is empty.

source

fn as_volatile_slice(&self) -> VolatileSlice<'_, BS<'_, Self::B>>

Gets a slice of memory for the entire region that supports volatile access.

source

fn get_ref<T: ByteValued>( &self, offset: usize, ) -> Result<VolatileRef<'_, T, BS<'_, Self::B>>>

Gets a VolatileRef at offset.

source

fn get_array_ref<T: ByteValued>( &self, offset: usize, n: usize, ) -> Result<VolatileArrayRef<'_, T, BS<'_, Self::B>>>

Returns a VolatileArrayRef of n elements starting at offset.

source

unsafe fn aligned_as_ref<T: ByteValued>(&self, offset: usize) -> Result<&T>

Returns a reference to an instance of T at offset.

§Safety

To use this safely, the caller must guarantee that there are no other users of the given chunk of memory for the lifetime of the result.

§Errors

If the resulting pointer is not aligned, this method will return an Error.

source

unsafe fn aligned_as_mut<T: ByteValued>(&self, offset: usize) -> Result<&mut T>

Returns a mutable reference to an instance of T at offset. Mutable accesses performed using the resulting reference are not automatically accounted for by the dirty bitmap tracking functionality.

§Safety

To use this safely, the caller must guarantee that there are no other users of the given chunk of memory for the lifetime of the result.

§Errors

If the resulting pointer is not aligned, this method will return an Error.

source

fn get_atomic_ref<T: AtomicInteger>(&self, offset: usize) -> Result<&T>

Returns a reference to an instance of T at offset. Mutable accesses performed using the resulting reference are not automatically accounted for by the dirty bitmap tracking functionality.

§Errors

If the resulting pointer is not aligned, this method will return an Error.

source

fn compute_end_offset(&self, base: usize, offset: usize) -> Result<usize>

Returns the sum of base and offset if the resulting address is valid.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a> VolatileMemory for &'a mut [u8]

§

type B = ()

source§

fn len(&self) -> usize

source§

fn get_slice( &self, offset: usize, count: usize, ) -> Result<VolatileSlice<'_, ()>>

Implementors§