Trait 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§

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ReadVolatile for &[u8]

Source§

impl ReadVolatile for File

Source§

impl ReadVolatile for TcpStream

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§