Trait vm_memory::io::WriteVolatile
source · pub trait WriteVolatile {
// Required method
fn write_volatile<B: BitmapSlice>(
&mut self,
buf: &VolatileSlice<'_, B>
) -> Result<usize, VolatileMemoryError>;
// Provided method
fn write_all_volatile<B: BitmapSlice>(
&mut self,
buf: &VolatileSlice<'_, B>
) -> Result<(), VolatileMemoryError> { ... }
}
Expand description
A version of the standard library’s [Write
] 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 write_volatile<B: BitmapSlice>(
&mut self,
buf: &VolatileSlice<'_, B>
) -> Result<usize, VolatileMemoryError>
fn write_volatile<B: BitmapSlice>( &mut self, buf: &VolatileSlice<'_, B> ) -> Result<usize, VolatileMemoryError>
Tries to write some bytes from the given VolatileSlice
buffer, returning how many bytes
were written.
The behavior of implementations should be identical to [Write::write
]
Provided Methods§
sourcefn write_all_volatile<B: BitmapSlice>(
&mut self,
buf: &VolatileSlice<'_, B>
) -> Result<(), VolatileMemoryError>
fn write_all_volatile<B: BitmapSlice>( &mut self, buf: &VolatileSlice<'_, B> ) -> Result<(), VolatileMemoryError>
Tries write the entire content of the given VolatileSlice
buffer to self
returning an
error if not all bytes could be written.
The default implementation is identical to that of [Write::write_all
]
Object Safety§
This trait is not object safe.