[−][src]Trait wasi_common::Handle
Generic interface for all WASI-compatible handles. We currently group these into two groups:
- OS-based resources (actual, real resources):
OsFile
,OsDir
,OsOther
, andStdio
, - virtual files and directories: VirtualDir
, and
InMemoryFile`.
Constructing Handle
s representing OS-based resources
Each type of handle can either be constructed directly (see docs entry for a specific handle
type such as OsFile
), or you can let the wasi_common
crate's machinery work it out
automatically for you using std::convert::TryInto
from std::fs::File
:
use std::convert::TryInto; use wasi_common::Handle; use std::fs::OpenOptions; let some_file = OpenOptions::new().read(true).open("some_file").unwrap(); let wasi_handle: Box<dyn Handle> = some_file.try_into().unwrap();
Required methods
fn as_any(&self) -> &dyn Any
fn try_clone(&self) -> Result<Box<dyn Handle>>
fn get_file_type(&self) -> Filetype
fn set_rights(&self, rights: HandleRights)
Provided methods
fn get_rights(&self) -> HandleRights
fn is_directory(&self) -> bool
fn is_tty(&self) -> bool
Test whether this descriptor is considered a tty within WASI.
Note that since WASI itself lacks an isatty
syscall and relies
on a conservative approximation, we use the same approximation here.
fn advise(
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
fn allocate(&self, _offset: Filesize, _len: Filesize) -> Result<()>
fn datasync(&self) -> Result<()>
fn fdstat_get(&self) -> Result<Fdflags>
fn fdstat_set_flags(&self, _fdflags: Fdflags) -> Result<()>
fn filestat_get(&self) -> Result<Filestat>
fn filestat_set_size(&self, _st_size: Filesize) -> Result<()>
fn filestat_set_times(
&self,
_atim: Timestamp,
_mtim: Timestamp,
_fst_flags: Fstflags
) -> Result<()>
&self,
_atim: Timestamp,
_mtim: Timestamp,
_fst_flags: Fstflags
) -> Result<()>
fn preadv(&self, _buf: &mut [IoSliceMut], _offset: u64) -> Result<usize>
fn pwritev(&self, _buf: &[IoSlice], _offset: u64) -> Result<usize>
fn read_vectored(&self, _iovs: &mut [IoSliceMut]) -> Result<usize>
fn readdir<'a>(
&'a self,
_cookie: Dircookie
) -> Result<Box<dyn Iterator<Item = Result<(Dirent, String)>> + 'a>>
&'a self,
_cookie: Dircookie
) -> Result<Box<dyn Iterator<Item = Result<(Dirent, String)>> + 'a>>
fn seek(&self, _offset: SeekFrom) -> Result<u64>
fn sync(&self) -> Result<()>
fn write_vectored(&self, _iovs: &[IoSlice]) -> Result<usize>
fn create_directory(&self, _path: &str) -> Result<()>
fn filestat_get_at(&self, _path: &str, _follow: bool) -> Result<Filestat>
fn filestat_set_times_at(
&self,
_path: &str,
_atim: Timestamp,
_mtim: Timestamp,
_fst_flags: Fstflags,
_follow: bool
) -> Result<()>
&self,
_path: &str,
_atim: Timestamp,
_mtim: Timestamp,
_fst_flags: Fstflags,
_follow: bool
) -> Result<()>
fn openat(
&self,
_path: &str,
_read: bool,
_write: bool,
_oflags: Oflags,
_fd_flags: Fdflags
) -> Result<Box<dyn Handle>>
&self,
_path: &str,
_read: bool,
_write: bool,
_oflags: Oflags,
_fd_flags: Fdflags
) -> Result<Box<dyn Handle>>
fn link(
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str,
_follow: bool
) -> Result<()>
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str,
_follow: bool
) -> Result<()>
fn readlink(&self, _path: &str, _buf: &mut [u8]) -> Result<usize>
fn readlinkat(&self, _path: &str) -> Result<String>
fn remove_directory(&self, _path: &str) -> Result<()>
fn rename(
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str
) -> Result<()>
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str
) -> Result<()>
fn symlink(&self, _old_path: &str, _new_path: &str) -> Result<()>
fn unlink_file(&self, _path: &str) -> Result<()>
Implementors
impl Handle for OsDir
[src]
fn as_any(&self) -> &dyn Any
[src]
fn try_clone(&self) -> Result<Box<dyn Handle>>
[src]
fn get_file_type(&self) -> Filetype
[src]
fn get_rights(&self) -> HandleRights
[src]
fn set_rights(&self, rights: HandleRights)
[src]
fn fdstat_get(&self) -> Result<Fdflags>
[src]
fn fdstat_set_flags(&self, fdflags: Fdflags) -> Result<()>
[src]
fn filestat_get(&self) -> Result<Filestat>
[src]
fn filestat_set_times(
&self,
atim: Timestamp,
mtim: Timestamp,
fst_flags: Fstflags
) -> Result<()>
[src]
&self,
atim: Timestamp,
mtim: Timestamp,
fst_flags: Fstflags
) -> Result<()>
fn readdir<'a>(
&'a self,
cookie: Dircookie
) -> Result<Box<dyn Iterator<Item = Result<(Dirent, String)>> + 'a>>
[src]
&'a self,
cookie: Dircookie
) -> Result<Box<dyn Iterator<Item = Result<(Dirent, String)>> + 'a>>
fn create_directory(&self, path: &str) -> Result<()>
[src]
fn filestat_get_at(&self, path: &str, follow: bool) -> Result<Filestat>
[src]
fn filestat_set_times_at(
&self,
path: &str,
atim: Timestamp,
mtim: Timestamp,
fst_flags: Fstflags,
follow: bool
) -> Result<()>
[src]
&self,
path: &str,
atim: Timestamp,
mtim: Timestamp,
fst_flags: Fstflags,
follow: bool
) -> Result<()>
fn openat(
&self,
path: &str,
read: bool,
write: bool,
oflags: Oflags,
fd_flags: Fdflags
) -> Result<Box<dyn Handle>>
[src]
&self,
path: &str,
read: bool,
write: bool,
oflags: Oflags,
fd_flags: Fdflags
) -> Result<Box<dyn Handle>>
fn link(
&self,
old_path: &str,
new_handle: Box<dyn Handle>,
new_path: &str,
follow: bool
) -> Result<()>
[src]
&self,
old_path: &str,
new_handle: Box<dyn Handle>,
new_path: &str,
follow: bool
) -> Result<()>
fn symlink(&self, old_path: &str, new_path: &str) -> Result<()>
[src]
fn readlink(&self, path: &str, buf: &mut [u8]) -> Result<usize>
[src]
fn readlinkat(&self, path: &str) -> Result<String>
[src]
fn rename(
&self,
old_path: &str,
new_handle: Box<dyn Handle>,
new_path: &str
) -> Result<()>
[src]
&self,
old_path: &str,
new_handle: Box<dyn Handle>,
new_path: &str
) -> Result<()>
fn remove_directory(&self, path: &str) -> Result<()>
[src]
fn unlink_file(&self, path: &str) -> Result<()>
[src]
impl Handle for OsFile
[src]
fn as_any(&self) -> &dyn Any
[src]
fn try_clone(&self) -> Result<Box<dyn Handle>>
[src]
fn get_file_type(&self) -> Filetype
[src]
fn get_rights(&self) -> HandleRights
[src]
fn set_rights(&self, rights: HandleRights)
[src]
fn advise(&self, advice: Advice, offset: Filesize, len: Filesize) -> Result<()>
[src]
fn allocate(&self, offset: Filesize, len: Filesize) -> Result<()>
[src]
fn datasync(&self) -> Result<()>
[src]
fn fdstat_get(&self) -> Result<Fdflags>
[src]
fn fdstat_set_flags(&self, fdflags: Fdflags) -> Result<()>
[src]
fn filestat_get(&self) -> Result<Filestat>
[src]
fn filestat_set_size(&self, size: Filesize) -> Result<()>
[src]
fn filestat_set_times(
&self,
atim: Timestamp,
mtim: Timestamp,
fst_flags: Fstflags
) -> Result<()>
[src]
&self,
atim: Timestamp,
mtim: Timestamp,
fst_flags: Fstflags
) -> Result<()>
fn preadv(&self, buf: &mut [IoSliceMut], offset: u64) -> Result<usize>
[src]
fn pwritev(&self, buf: &[IoSlice], offset: u64) -> Result<usize>
[src]
fn read_vectored(&self, iovs: &mut [IoSliceMut]) -> Result<usize>
[src]
fn seek(&self, offset: SeekFrom) -> Result<u64>
[src]
fn sync(&self) -> Result<()>
[src]
fn write_vectored(&self, iovs: &[IoSlice]) -> Result<usize>
[src]
impl Handle for OsOther
[src]
fn as_any(&self) -> &dyn Any
[src]
fn try_clone(&self) -> Result<Box<dyn Handle>>
[src]
fn get_file_type(&self) -> Filetype
[src]
fn get_rights(&self) -> HandleRights
[src]
fn set_rights(&self, new_rights: HandleRights)
[src]
fn fdstat_get(&self) -> Result<Fdflags>
[src]
fn fdstat_set_flags(&self, fdflags: Fdflags) -> Result<()>
[src]
fn read_vectored(&self, iovs: &mut [IoSliceMut]) -> Result<usize>
[src]
fn write_vectored(&self, iovs: &[IoSlice]) -> Result<usize>
[src]
impl Handle for InMemoryFile
[src]
fn as_any(&self) -> &dyn Any
[src]
fn try_clone(&self) -> Result<Box<dyn Handle>>
[src]
fn get_file_type(&self) -> Filetype
[src]
fn get_rights(&self) -> HandleRights
[src]
fn set_rights(&self, rights: HandleRights)
[src]
fn advise(
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
[src]
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
fn allocate(&self, offset: Filesize, len: Filesize) -> Result<()>
[src]
fn fdstat_get(&self) -> Result<Fdflags>
[src]
fn fdstat_set_flags(&self, fdflags: Fdflags) -> Result<()>
[src]
fn filestat_get(&self) -> Result<Filestat>
[src]
fn filestat_set_size(&self, st_size: Filesize) -> Result<()>
[src]
fn preadv(&self, buf: &mut [IoSliceMut], offset: Filesize) -> Result<usize>
[src]
fn pwritev(&self, buf: &[IoSlice], offset: Filesize) -> Result<usize>
[src]
fn read_vectored(&self, iovs: &mut [IoSliceMut]) -> Result<usize>
[src]
fn seek(&self, offset: SeekFrom) -> Result<Filesize>
[src]
fn write_vectored(&self, iovs: &[IoSlice]) -> Result<usize>
[src]
fn create_directory(&self, _path: &str) -> Result<()>
[src]
fn openat(
&self,
path: &str,
read: bool,
write: bool,
oflags: Oflags,
fd_flags: Fdflags
) -> Result<Box<dyn Handle>>
[src]
&self,
path: &str,
read: bool,
write: bool,
oflags: Oflags,
fd_flags: Fdflags
) -> Result<Box<dyn Handle>>
fn link(
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str,
_follow: bool
) -> Result<()>
[src]
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str,
_follow: bool
) -> Result<()>
fn readlink(&self, _path: &str, _buf: &mut [u8]) -> Result<usize>
[src]
fn readlinkat(&self, _path: &str) -> Result<String>
[src]
fn rename(
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str
) -> Result<()>
[src]
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str
) -> Result<()>
fn remove_directory(&self, _path: &str) -> Result<()>
[src]
fn symlink(&self, _old_path: &str, _new_path: &str) -> Result<()>
[src]
fn unlink_file(&self, _path: &str) -> Result<()>
[src]
impl Handle for VirtualDir
[src]
fn as_any(&self) -> &dyn Any
[src]
fn try_clone(&self) -> Result<Box<dyn Handle>>
[src]
fn get_file_type(&self) -> Filetype
[src]
fn get_rights(&self) -> HandleRights
[src]
fn set_rights(&self, rights: HandleRights)
[src]
fn filestat_get(&self) -> Result<Filestat>
[src]
fn readdir(
&self,
cookie: Dircookie
) -> Result<Box<dyn Iterator<Item = Result<(Dirent, String)>>>>
[src]
&self,
cookie: Dircookie
) -> Result<Box<dyn Iterator<Item = Result<(Dirent, String)>>>>
fn create_directory(&self, path: &str) -> Result<()>
[src]
fn filestat_get_at(&self, path: &str, _follow: bool) -> Result<Filestat>
[src]
fn filestat_set_times_at(
&self,
path: &str,
atim: Timestamp,
mtim: Timestamp,
fst_flags: Fstflags,
_follow: bool
) -> Result<()>
[src]
&self,
path: &str,
atim: Timestamp,
mtim: Timestamp,
fst_flags: Fstflags,
_follow: bool
) -> Result<()>
fn openat(
&self,
path: &str,
read: bool,
write: bool,
oflags: Oflags,
fd_flags: Fdflags
) -> Result<Box<dyn Handle>>
[src]
&self,
path: &str,
read: bool,
write: bool,
oflags: Oflags,
fd_flags: Fdflags
) -> Result<Box<dyn Handle>>
fn readlinkat(&self, _path: &str) -> Result<String>
[src]
fn remove_directory(&self, path: &str) -> Result<()>
[src]
fn unlink_file(&self, path: &str) -> Result<()>
[src]
impl<R: Read + Any> Handle for ReadPipe<R>
[src]
fn as_any(&self) -> &dyn Any
[src]
fn try_clone(&self) -> Result<Box<dyn Handle>>
[src]
fn get_file_type(&self) -> Filetype
[src]
fn get_rights(&self) -> HandleRights
[src]
fn set_rights(&self, rights: HandleRights)
[src]
fn advise(
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
[src]
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
fn allocate(&self, _offset: Filesize, _len: Filesize) -> Result<()>
[src]
fn fdstat_set_flags(&self, _fdflags: Fdflags) -> Result<()>
[src]
fn filestat_get(&self) -> Result<Filestat>
[src]
fn filestat_set_size(&self, _st_size: Filesize) -> Result<()>
[src]
fn preadv(&self, buf: &mut [IoSliceMut], offset: Filesize) -> Result<usize>
[src]
fn seek(&self, _offset: SeekFrom) -> Result<Filesize>
[src]
fn read_vectored(&self, iovs: &mut [IoSliceMut]) -> Result<usize>
[src]
fn create_directory(&self, _path: &str) -> Result<()>
[src]
fn openat(
&self,
_path: &str,
_read: bool,
_write: bool,
_oflags: Oflags,
_fd_flags: Fdflags
) -> Result<Box<dyn Handle>>
[src]
&self,
_path: &str,
_read: bool,
_write: bool,
_oflags: Oflags,
_fd_flags: Fdflags
) -> Result<Box<dyn Handle>>
fn link(
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str,
_follow: bool
) -> Result<()>
[src]
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str,
_follow: bool
) -> Result<()>
fn readlink(&self, _path: &str, _buf: &mut [u8]) -> Result<usize>
[src]
fn readlinkat(&self, _path: &str) -> Result<String>
[src]
fn rename(
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str
) -> Result<()>
[src]
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str
) -> Result<()>
fn remove_directory(&self, _path: &str) -> Result<()>
[src]
fn symlink(&self, _old_path: &str, _new_path: &str) -> Result<()>
[src]
fn unlink_file(&self, _path: &str) -> Result<()>
[src]
impl<W: Write + Any> Handle for WritePipe<W>
[src]
fn as_any(&self) -> &dyn Any
[src]
fn try_clone(&self) -> Result<Box<dyn Handle>>
[src]
fn get_file_type(&self) -> Filetype
[src]
fn get_rights(&self) -> HandleRights
[src]
fn set_rights(&self, rights: HandleRights)
[src]
fn advise(
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
[src]
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
fn allocate(&self, _offset: Filesize, _len: Filesize) -> Result<()>
[src]
fn fdstat_set_flags(&self, _fdflags: Fdflags) -> Result<()>
[src]
fn filestat_get(&self) -> Result<Filestat>
[src]
fn filestat_set_size(&self, _st_size: Filesize) -> Result<()>
[src]
fn pwritev(&self, buf: &[IoSlice], offset: Filesize) -> Result<usize>
[src]
fn seek(&self, _offset: SeekFrom) -> Result<Filesize>
[src]
fn write_vectored(&self, iovs: &[IoSlice]) -> Result<usize>
[src]
fn create_directory(&self, _path: &str) -> Result<()>
[src]
fn openat(
&self,
_path: &str,
_read: bool,
_write: bool,
_oflags: Oflags,
_fd_flags: Fdflags
) -> Result<Box<dyn Handle>>
[src]
&self,
_path: &str,
_read: bool,
_write: bool,
_oflags: Oflags,
_fd_flags: Fdflags
) -> Result<Box<dyn Handle>>
fn link(
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str,
_follow: bool
) -> Result<()>
[src]
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str,
_follow: bool
) -> Result<()>
fn readlink(&self, _path: &str, _buf: &mut [u8]) -> Result<usize>
[src]
fn readlinkat(&self, _path: &str) -> Result<String>
[src]
fn rename(
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str
) -> Result<()>
[src]
&self,
_old_path: &str,
_new_handle: Box<dyn Handle>,
_new_path: &str
) -> Result<()>