Trait vm_memory::io::ReadVolatile
source · pub trait ReadVolatile {
// Required method
fn read_volatile<B: BitmapSlice>(
&mut self,
buf: &mut VolatileSlice<'_, B>
) -> Result<usize, VolatileMemoryError>;
// Provided method
fn read_exact_volatile<B: BitmapSlice>(
&mut self,
buf: &mut VolatileSlice<'_, B>
) -> Result<(), VolatileMemoryError> { ... }
}Expand description
A version of the standard library’s [Read] trait that operates on volatile memory instead of
slices
This trait is needed as rust slices (&[u8] and &mut [u8]) cannot be used when operating on
guest memory 1.
Required Methods§
sourcefn read_volatile<B: BitmapSlice>(
&mut self,
buf: &mut VolatileSlice<'_, B>
) -> Result<usize, VolatileMemoryError>
fn read_volatile<B: BitmapSlice>( &mut self, buf: &mut VolatileSlice<'_, B> ) -> Result<usize, VolatileMemoryError>
Tries to read some bytes into the given VolatileSlice buffer, returning how many bytes
were read.
The behavior of implementations should be identical to [Read::read]
Provided Methods§
sourcefn read_exact_volatile<B: BitmapSlice>(
&mut self,
buf: &mut VolatileSlice<'_, B>
) -> Result<(), VolatileMemoryError>
fn read_exact_volatile<B: BitmapSlice>( &mut self, buf: &mut VolatileSlice<'_, B> ) -> Result<(), VolatileMemoryError>
Tries to fill the given VolatileSlice buffer by reading from self returning an error
if insufficient bytes could be read.
The default implementation is identical to that of [Read::read_exact]
Object Safety§
This trait is not object safe.