Trait vm_memory::volatile_memory::VolatileMemory
source · [−]pub trait VolatileMemory {
type B: Bitmap;
fn len(&self) -> usize;
fn get_slice(
&self,
offset: usize,
count: usize
) -> Result<VolatileSlice<'_, BS<'_, Self::B>>>;
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
Required Methods
Returns a VolatileSlice
of count
bytes starting at
offset
.
Provided Methods
fn as_volatile_slice(&self) -> VolatileSlice<'_, BS<'_, Self::B>>
fn as_volatile_slice(&self) -> VolatileSlice<'_, BS<'_, Self::B>>
Gets a slice of memory for the entire region that supports volatile access.
fn get_ref<T: ByteValued>(
&self,
offset: usize
) -> Result<VolatileRef<'_, T, BS<'_, Self::B>>>
fn get_ref<T: ByteValued>(
&self,
offset: usize
) -> Result<VolatileRef<'_, T, BS<'_, Self::B>>>
Gets a VolatileRef
at offset
.
fn get_array_ref<T: ByteValued>(
&self,
offset: usize,
n: usize
) -> Result<VolatileArrayRef<'_, T, BS<'_, Self::B>>>
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
.
unsafe fn aligned_as_ref<T: ByteValued>(&self, offset: usize) -> Result<&T>
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>
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
.