pub trait WasiFile: Debug + AsyncRead + AsyncWrite + AsyncSeek + Unpin + Upcastable {
    // Required methods
    fn last_accessed(&self) -> u64;
    fn last_modified(&self) -> u64;
    fn created_time(&self) -> u64;
    fn size(&self) -> u64;
    fn set_len(&mut self, new_size: u64) -> Result<(), FsError>;
    fn unlink(&mut self) -> Result<(), FsError>;
    fn poll_read_ready(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>
    ) -> Poll<Result<usize, Error>>;
    fn poll_write_ready(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>
    ) -> Poll<Result<usize, Error>>;

    // Provided methods
    fn is_open(&self) -> bool { ... }
    fn get_special_fd(&self) -> Option<u32> { ... }
}
Expand description

This trait relies on your file closing when it goes out of scope via Drop

Required Methods§

source

fn last_accessed(&self) -> u64

the last time the file was accessed in nanoseconds as a UNIX timestamp

source

fn last_modified(&self) -> u64

the last time the file was modified in nanoseconds as a UNIX timestamp

source

fn created_time(&self) -> u64

the time at which the file was created in nanoseconds as a UNIX timestamp

source

fn size(&self) -> u64

the size of the file in bytes

source

fn set_len(&mut self, new_size: u64) -> Result<(), FsError>

Change the size of the file, if the new_size is greater than the current size the extra bytes will be allocated and zeroed

Request deletion of the file

source

fn poll_read_ready( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Result<usize, Error>>

Polls the file for when there is data to be read

source

fn poll_write_ready( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Result<usize, Error>>

Polls the file for when it is available for writing

Provided Methods§

source

fn is_open(&self) -> bool

Indicates if the file is opened or closed. This function must not block Defaults to a status of being constantly open

source

fn get_special_fd(&self) -> Option<u32>

Used for “special” files such as stdin, stdout and stderr. Always returns the same file descriptor (0, 1 or 2). Returns None on normal files

Implementors§

source§

impl VirtualFile for ArcBoxFile

source§

impl VirtualFile for CombineFile

source§

impl VirtualFile for DualWriteFile

source§

impl VirtualFile for File

source§

impl VirtualFile for virtual_fs::host_fs::Stderr

source§

impl VirtualFile for virtual_fs::host_fs::Stdin

source§

impl VirtualFile for virtual_fs::host_fs::Stdout

source§

impl VirtualFile for virtual_fs::mem_fs::stdio::Stderr

source§

impl VirtualFile for virtual_fs::mem_fs::stdio::Stdin

source§

impl VirtualFile for virtual_fs::mem_fs::stdio::Stdout

source§

impl VirtualFile for NullFile

source§

impl VirtualFile for RandomFile

source§

impl VirtualFile for DeviceFile

source§

impl VirtualFile for ZeroFile

source§

impl VirtualFile for Pipe

source§

impl<T> VirtualFile for ArcFile<T>where T: VirtualFile + Send + Sync + 'static,