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§

source

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§

source

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.

Implementations on Foreign Types§

source§

impl WriteVolatile for &mut [u8]

source§

impl WriteVolatile for Vec<u8>

source§

impl WriteVolatile for File

source§

impl WriteVolatile for Cursor<&mut [u8]>

source§

impl WriteVolatile for Stdout

source§

impl WriteVolatile for BorrowedFd<'_>

source§

impl WriteVolatile for OwnedFd

source§

impl WriteVolatile for UnixStream

Implementors§