[−][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
pub fn as_any(&self) -> &dyn Any
[src]
pub fn try_clone(&self) -> Result<Box<dyn Handle>>
[src]
pub fn get_file_type(&self) -> Filetype
[src]
pub fn set_rights(&self, rights: HandleRights)
[src]
Provided methods
pub fn get_rights(&self) -> HandleRights
[src]
pub fn is_directory(&self) -> bool
[src]
pub fn is_tty(&self) -> bool
[src]
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.
pub fn advise(
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
[src]
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
pub fn allocate(&self, _offset: Filesize, _len: Filesize) -> Result<()>
[src]
pub fn datasync(&self) -> Result<()>
[src]
pub fn fdstat_get(&self) -> Result<Fdflags>
[src]
pub fn fdstat_set_flags(&self, _fdflags: Fdflags) -> Result<()>
[src]
pub fn filestat_get(&self) -> Result<Filestat>
[src]
pub fn filestat_set_size(&self, _st_size: Filesize) -> Result<()>
[src]
pub fn filestat_set_times(
&self,
_atim: Timestamp,
_mtim: Timestamp,
_fst_flags: Fstflags
) -> Result<()>
[src]
&self,
_atim: Timestamp,
_mtim: Timestamp,
_fst_flags: Fstflags
) -> Result<()>
pub fn preadv(&self, _buf: &mut [IoSliceMut<'_>], _offset: u64) -> Result<usize>
[src]
pub fn pwritev(&self, _buf: &[IoSlice<'_>], _offset: u64) -> Result<usize>
[src]
pub fn read_vectored(&self, _iovs: &mut [IoSliceMut<'_>]) -> Result<usize>
[src]
pub 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>>
pub fn seek(&self, _offset: SeekFrom) -> Result<u64>
[src]
pub fn sync(&self) -> Result<()>
[src]
pub fn write_vectored(&self, _iovs: &[IoSlice<'_>]) -> Result<usize>
[src]
pub fn create_directory(&self, _path: &str) -> Result<()>
[src]
pub fn filestat_get_at(&self, _path: &str, _follow: bool) -> Result<Filestat>
[src]
pub 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<()>
pub 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>>
pub 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<()>
pub fn readlink(&self, _path: &str, _buf: &mut [u8]) -> Result<usize>
[src]
pub fn readlinkat(&self, _path: &str) -> Result<String>
[src]
pub fn remove_directory(&self, _path: &str) -> Result<()>
[src]
pub 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<()>
pub fn symlink(&self, _old_path: &str, _new_path: &str) -> Result<()>
[src]
pub fn unlink_file(&self, _path: &str) -> Result<()>
[src]
Implementors
impl Handle for OsDir
[src]
pub fn as_any(&self) -> &dyn Any
[src]
pub fn try_clone(&self) -> Result<Box<dyn Handle>>
[src]
pub fn get_file_type(&self) -> Filetype
[src]
pub fn get_rights(&self) -> HandleRights
[src]
pub fn set_rights(&self, rights: HandleRights)
[src]
pub fn fdstat_get(&self) -> Result<Fdflags>
[src]
pub fn fdstat_set_flags(&self, fdflags: Fdflags) -> Result<()>
[src]
pub fn filestat_get(&self) -> Result<Filestat>
[src]
pub fn filestat_set_times(
&self,
atim: Timestamp,
mtim: Timestamp,
fst_flags: Fstflags
) -> Result<()>
[src]
&self,
atim: Timestamp,
mtim: Timestamp,
fst_flags: Fstflags
) -> Result<()>
pub 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>>
pub fn create_directory(&self, path: &str) -> Result<()>
[src]
pub fn filestat_get_at(&self, path: &str, follow: bool) -> Result<Filestat>
[src]
pub 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<()>
pub 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>>
pub 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<()>
pub fn symlink(&self, old_path: &str, new_path: &str) -> Result<()>
[src]
pub fn readlink(&self, path: &str, buf: &mut [u8]) -> Result<usize>
[src]
pub fn readlinkat(&self, path: &str) -> Result<String>
[src]
pub 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<()>
pub fn remove_directory(&self, path: &str) -> Result<()>
[src]
pub fn unlink_file(&self, path: &str) -> Result<()>
[src]
impl Handle for OsFile
[src]
pub fn as_any(&self) -> &dyn Any
[src]
pub fn try_clone(&self) -> Result<Box<dyn Handle>>
[src]
pub fn get_file_type(&self) -> Filetype
[src]
pub fn get_rights(&self) -> HandleRights
[src]
pub fn set_rights(&self, rights: HandleRights)
[src]
pub fn advise(
&self,
advice: Advice,
offset: Filesize,
len: Filesize
) -> Result<()>
[src]
&self,
advice: Advice,
offset: Filesize,
len: Filesize
) -> Result<()>
pub fn allocate(&self, offset: Filesize, len: Filesize) -> Result<()>
[src]
pub fn datasync(&self) -> Result<()>
[src]
pub fn fdstat_get(&self) -> Result<Fdflags>
[src]
pub fn fdstat_set_flags(&self, fdflags: Fdflags) -> Result<()>
[src]
pub fn filestat_get(&self) -> Result<Filestat>
[src]
pub fn filestat_set_size(&self, size: Filesize) -> Result<()>
[src]
pub fn filestat_set_times(
&self,
atim: Timestamp,
mtim: Timestamp,
fst_flags: Fstflags
) -> Result<()>
[src]
&self,
atim: Timestamp,
mtim: Timestamp,
fst_flags: Fstflags
) -> Result<()>
pub fn preadv(&self, buf: &mut [IoSliceMut<'_>], offset: u64) -> Result<usize>
[src]
pub fn pwritev(&self, buf: &[IoSlice<'_>], offset: u64) -> Result<usize>
[src]
pub fn read_vectored(&self, iovs: &mut [IoSliceMut<'_>]) -> Result<usize>
[src]
pub fn seek(&self, offset: SeekFrom) -> Result<u64>
[src]
pub fn sync(&self) -> Result<()>
[src]
pub fn write_vectored(&self, iovs: &[IoSlice<'_>]) -> Result<usize>
[src]
impl Handle for OsOther
[src]
pub fn as_any(&self) -> &dyn Any
[src]
pub fn try_clone(&self) -> Result<Box<dyn Handle>>
[src]
pub fn get_file_type(&self) -> Filetype
[src]
pub fn get_rights(&self) -> HandleRights
[src]
pub fn set_rights(&self, new_rights: HandleRights)
[src]
pub fn fdstat_get(&self) -> Result<Fdflags>
[src]
pub fn fdstat_set_flags(&self, fdflags: Fdflags) -> Result<()>
[src]
pub fn read_vectored(&self, iovs: &mut [IoSliceMut<'_>]) -> Result<usize>
[src]
pub fn write_vectored(&self, iovs: &[IoSlice<'_>]) -> Result<usize>
[src]
impl Handle for InMemoryFile
[src]
pub fn as_any(&self) -> &dyn Any
[src]
pub fn try_clone(&self) -> Result<Box<dyn Handle>>
[src]
pub fn get_file_type(&self) -> Filetype
[src]
pub fn get_rights(&self) -> HandleRights
[src]
pub fn set_rights(&self, rights: HandleRights)
[src]
pub fn advise(
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
[src]
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
pub fn allocate(&self, offset: Filesize, len: Filesize) -> Result<()>
[src]
pub fn fdstat_get(&self) -> Result<Fdflags>
[src]
pub fn fdstat_set_flags(&self, fdflags: Fdflags) -> Result<()>
[src]
pub fn filestat_get(&self) -> Result<Filestat>
[src]
pub fn filestat_set_size(&self, st_size: Filesize) -> Result<()>
[src]
pub fn preadv(
&self,
buf: &mut [IoSliceMut<'_>],
offset: Filesize
) -> Result<usize>
[src]
&self,
buf: &mut [IoSliceMut<'_>],
offset: Filesize
) -> Result<usize>
pub fn pwritev(&self, buf: &[IoSlice<'_>], offset: Filesize) -> Result<usize>
[src]
pub fn read_vectored(&self, iovs: &mut [IoSliceMut<'_>]) -> Result<usize>
[src]
pub fn seek(&self, offset: SeekFrom) -> Result<Filesize>
[src]
pub fn write_vectored(&self, iovs: &[IoSlice<'_>]) -> Result<usize>
[src]
pub fn create_directory(&self, _path: &str) -> Result<()>
[src]
pub 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>>
pub 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<()>
pub fn readlink(&self, _path: &str, _buf: &mut [u8]) -> Result<usize>
[src]
pub fn readlinkat(&self, _path: &str) -> Result<String>
[src]
pub 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<()>
pub fn remove_directory(&self, _path: &str) -> Result<()>
[src]
pub fn symlink(&self, _old_path: &str, _new_path: &str) -> Result<()>
[src]
pub fn unlink_file(&self, _path: &str) -> Result<()>
[src]
impl Handle for VirtualDir
[src]
pub fn as_any(&self) -> &dyn Any
[src]
pub fn try_clone(&self) -> Result<Box<dyn Handle>>
[src]
pub fn get_file_type(&self) -> Filetype
[src]
pub fn get_rights(&self) -> HandleRights
[src]
pub fn set_rights(&self, rights: HandleRights)
[src]
pub fn filestat_get(&self) -> Result<Filestat>
[src]
pub 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)>>>>
pub fn create_directory(&self, path: &str) -> Result<()>
[src]
pub fn filestat_get_at(&self, path: &str, _follow: bool) -> Result<Filestat>
[src]
pub 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<()>
pub 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>>
pub fn readlinkat(&self, _path: &str) -> Result<String>
[src]
pub fn remove_directory(&self, path: &str) -> Result<()>
[src]
pub fn unlink_file(&self, path: &str) -> Result<()>
[src]
impl<R: Read + Any> Handle for ReadPipe<R>
[src]
pub fn as_any(&self) -> &dyn Any
[src]
pub fn try_clone(&self) -> Result<Box<dyn Handle>>
[src]
pub fn get_file_type(&self) -> Filetype
[src]
pub fn get_rights(&self) -> HandleRights
[src]
pub fn set_rights(&self, rights: HandleRights)
[src]
pub fn advise(
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
[src]
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
pub fn allocate(&self, _offset: Filesize, _len: Filesize) -> Result<()>
[src]
pub fn fdstat_set_flags(&self, _fdflags: Fdflags) -> Result<()>
[src]
pub fn filestat_get(&self) -> Result<Filestat>
[src]
pub fn filestat_set_size(&self, _st_size: Filesize) -> Result<()>
[src]
pub fn preadv(
&self,
buf: &mut [IoSliceMut<'_>],
offset: Filesize
) -> Result<usize>
[src]
&self,
buf: &mut [IoSliceMut<'_>],
offset: Filesize
) -> Result<usize>
pub fn seek(&self, _offset: SeekFrom) -> Result<Filesize>
[src]
pub fn read_vectored(&self, iovs: &mut [IoSliceMut<'_>]) -> Result<usize>
[src]
pub fn create_directory(&self, _path: &str) -> Result<()>
[src]
pub 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>>
pub 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<()>
pub fn readlink(&self, _path: &str, _buf: &mut [u8]) -> Result<usize>
[src]
pub fn readlinkat(&self, _path: &str) -> Result<String>
[src]
pub 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<()>
pub fn remove_directory(&self, _path: &str) -> Result<()>
[src]
pub fn symlink(&self, _old_path: &str, _new_path: &str) -> Result<()>
[src]
pub fn unlink_file(&self, _path: &str) -> Result<()>
[src]
impl<W: Write + Any> Handle for WritePipe<W>
[src]
pub fn as_any(&self) -> &dyn Any
[src]
pub fn try_clone(&self) -> Result<Box<dyn Handle>>
[src]
pub fn get_file_type(&self) -> Filetype
[src]
pub fn get_rights(&self) -> HandleRights
[src]
pub fn set_rights(&self, rights: HandleRights)
[src]
pub fn advise(
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
[src]
&self,
_advice: Advice,
_offset: Filesize,
_len: Filesize
) -> Result<()>
pub fn allocate(&self, _offset: Filesize, _len: Filesize) -> Result<()>
[src]
pub fn fdstat_set_flags(&self, _fdflags: Fdflags) -> Result<()>
[src]
pub fn filestat_get(&self) -> Result<Filestat>
[src]
pub fn filestat_set_size(&self, _st_size: Filesize) -> Result<()>
[src]
pub fn pwritev(&self, buf: &[IoSlice<'_>], offset: Filesize) -> Result<usize>
[src]
pub fn seek(&self, _offset: SeekFrom) -> Result<Filesize>
[src]
pub fn write_vectored(&self, iovs: &[IoSlice<'_>]) -> Result<usize>
[src]
pub fn create_directory(&self, _path: &str) -> Result<()>
[src]
pub 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>>
pub 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<()>
pub fn readlink(&self, _path: &str, _buf: &mut [u8]) -> Result<usize>
[src]
pub fn readlinkat(&self, _path: &str) -> Result<String>
[src]
pub 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<()>