[−][src]Trait vm_memory::volatile_memory::VolatileMemory
Types that support raw volatile access to their data.
Required methods
pub fn len(&self) -> usize
Gets the size of this slice.
pub fn get_slice(
&self,
offset: usize,
count: usize
) -> Result<VolatileSlice<'_>>
&self,
offset: usize,
count: usize
) -> Result<VolatileSlice<'_>>
Returns a VolatileSlice
of count
bytes starting at
offset
.
Provided methods
pub fn is_empty(&self) -> bool
Check whether the region is empty.
pub fn as_volatile_slice(&self) -> VolatileSlice<'_>
Gets a slice of memory for the entire region that supports volatile access.
pub fn get_ref<T: ByteValued>(
&self,
offset: usize
) -> Result<VolatileRef<'_, T>>
&self,
offset: usize
) -> Result<VolatileRef<'_, T>>
Gets a VolatileRef
at offset
.
pub 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
.
pub 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
.
pub unsafe fn aligned_as_mut<T: ByteValued>(
&self,
offset: usize
) -> Result<&mut T>
&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
.
pub fn get_atomic_ref<T: AtomicInteger>(&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
.
pub fn compute_end_offset(&self, base: usize, offset: usize) -> Result<usize>
Returns the sum of base
and offset
if the resulting address is valid.
Implementations on Foreign Types
impl<'a> VolatileMemory for &'a mut [u8]
[src]
pub fn len(&self) -> usize
[src]
pub fn get_slice(
&self,
offset: usize,
count: usize
) -> Result<VolatileSlice<'_>>
[src]
&self,
offset: usize,
count: usize
) -> Result<VolatileSlice<'_>>