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§

source

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§

source

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.

Implementations on Foreign Types§

source§

impl ReadVolatile for &[u8]

source§

impl ReadVolatile for File

source§

impl ReadVolatile for BorrowedFd<'_>

source§

impl ReadVolatile for OwnedFd

source§

impl ReadVolatile for UnixStream

source§

impl<T> ReadVolatile for Cursor<T>
where T: AsRef<[u8]>,

Implementors§