[−][src]Trait vm_memory::volatile_memory::VolatileMemory
Types that support raw volatile access to their data.
Required methods
fn len(&self) -> usize
Gets the size of this slice.
fn get_slice(&self, offset: usize, count: usize) -> Result<VolatileSlice>
Returns a VolatileSlice
of count
bytes starting at
offset
.
Provided methods
fn is_empty(&self) -> bool
Check whether the region is empty.
fn as_volatile_slice(&self) -> VolatileSlice
Gets a slice of memory for the entire region that supports volatile access.
fn get_ref<T: ByteValued>(&self, offset: usize) -> Result<VolatileRef<T>>
Gets a VolatileRef
at offset
.
fn get_array_ref<T: ByteValued>(
&self,
offset: usize,
n: usize
) -> Result<VolatileArrayRef<T>>
&self,
offset: usize,
n: usize
) -> Result<VolatileArrayRef<T>>
Returns a VolatileArrayRef
of n
elements starting at
offset
.
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
.
unsafe fn aligned_as_mut<T: ByteValued>(&self, offset: usize) -> Result<&mut T>
Returns a mutable 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
.
fn get_atomic_ref<T: AtomicValued>(&self, offset: usize) -> Result<&T>
Returns a reference to an instance of T
at offset
.
Errors
If the resulting pointer is not aligned, this method will return an
Error
.
fn compute_end_offset(&self, base: usize, offset: usize) -> Result<usize>
Returns the sum of base
and offset
if the resulting address is valid.