[][src]Trait wasi_common::FileContents

pub trait FileContents {
    fn max_size(&self) -> Filesize;
fn size(&self) -> Filesize;
fn resize(&mut self, new_size: Filesize) -> Result<()>;
fn pwritev(&mut self, iovs: &[IoSlice], offset: Filesize) -> Result<usize>;
fn preadv(&self, iovs: &mut [IoSliceMut], offset: Filesize) -> Result<usize>;
fn pwrite(&mut self, buf: &[u8], offset: Filesize) -> Result<usize>;
fn pread(&self, buf: &mut [u8], offset: Filesize) -> Result<usize>; }

Required methods

fn max_size(&self) -> Filesize

The implementation-defined maximum size of the store corresponding to a FileContents implementation.

fn size(&self) -> Filesize

The current number of bytes this FileContents describes.

fn resize(&mut self, new_size: Filesize) -> Result<()>

Resize to hold new_size number of bytes, or error if this is not possible.

fn pwritev(&mut self, iovs: &[IoSlice], offset: Filesize) -> Result<usize>

Write a list of IoSlice starting at offset. offset plus the total size of all iovs is guaranteed to not exceed max_size. Implementations must not indicate more bytes have been written than can be held by iovs.

fn preadv(&self, iovs: &mut [IoSliceMut], offset: Filesize) -> Result<usize>

Read from the file from offset, filling a list of IoSlice. The returend size must not be more than the capactiy of iovs, and must not exceed the limit reported by self.max_size().

fn pwrite(&mut self, buf: &[u8], offset: Filesize) -> Result<usize>

Write contents from buf to this file starting at offset. offset plus the length of buf is guaranteed to not exceed max_size. Implementations must not indicate more bytes have been written than the size of buf.

fn pread(&self, buf: &mut [u8], offset: Filesize) -> Result<usize>

Read from the file at offset, filling buf. The returned size must not be more than the capacity of buf, and offset plus the returned size must not exceed self.max_size().

Loading content...

Implementors

Loading content...