[][src]Struct wasmer_wasi::state::WasiFs

pub struct WasiFs {
    pub preopen_fds: Vec<u32>,
    pub name_map: HashMap<String, Inode>,
    pub inodes: Arena<InodeVal>,
    pub fd_map: HashMap<u32, Fd>,
    pub next_fd: Cell<u32>,
    pub orphan_fds: HashMap<Inode, InodeVal>,
    pub stdout: Box<dyn WasiFile>,
    pub stderr: Box<dyn WasiFile>,
    pub stdin: Box<dyn WasiFile>,
    // some fields omitted
}

Warning, modifying these fields directly may cause invariants to break and should be considered unsafe. These fields may be made private in a future release

Fields

preopen_fds: Vec<u32>name_map: HashMap<String, Inode>inodes: Arena<InodeVal>fd_map: HashMap<u32, Fd>next_fd: Cell<u32>orphan_fds: HashMap<Inode, InodeVal>

for fds still open after the file has been deleted

stdout: Box<dyn WasiFile>stderr: Box<dyn WasiFile>stdin: Box<dyn WasiFile>

Methods

impl WasiFs[src]

pub fn new(
    preopened_dirs: &[String],
    mapped_dirs: &[(String, PathBuf)]
) -> Result<Self, String>
[src]

pub fn open_file_at(
    &mut self,
    base: __wasi_fd_t,
    file: Box<dyn WasiFile>,
    open_flags: u16,
    name: String,
    rights: __wasi_rights_t,
    rights_inheriting: __wasi_rights_t,
    flags: __wasi_fdflags_t
) -> Result<__wasi_fd_t, WasiFsError>
[src]

Opens a user-supplied file in the directory specified with the name and flags given

pub fn swap_file(
    &mut self,
    fd: __wasi_fd_t,
    file: Box<dyn WasiFile>
) -> Result<Option<Box<dyn WasiFile>>, WasiFsError>
[src]

Change the backing of a given file descriptor Returns the old backing TODO: add examples

pub fn get_inode_at_path(
    &mut self,
    base: __wasi_fd_t,
    path: &str,
    follow_symlinks: bool
) -> Result<Inode, __wasi_errno_t>
[src]

gets a host file from a base directory and a path this function ensures the fs remains sandboxed

pub fn get_parent_inode_at_path(
    &mut self,
    base: __wasi_fd_t,
    path: &Path,
    follow_symlinks: bool
) -> Result<(Inode, String), __wasi_errno_t>
[src]

Returns the parent Dir or Root that the file at a given path is in and the file name stripped off

pub fn get_fd(&self, fd: __wasi_fd_t) -> Result<&Fd, __wasi_errno_t>[src]

pub fn get_inodeval_mut(
    &mut self,
    fd: __wasi_fd_t
) -> Result<&mut InodeVal, __wasi_errno_t>
[src]

gets either a normal inode or an orphaned inode

pub fn filestat_fd(
    &self,
    fd: __wasi_fd_t
) -> Result<__wasi_filestat_t, __wasi_errno_t>
[src]

pub fn fdstat(&self, fd: __wasi_fd_t) -> Result<__wasi_fdstat_t, __wasi_errno_t>[src]

pub fn prestat_fd(
    &self,
    fd: __wasi_fd_t
) -> Result<__wasi_prestat_t, __wasi_errno_t>
[src]

pub fn flush(&mut self, fd: __wasi_fd_t) -> Result<(), __wasi_errno_t>[src]

pub fn create_inode(
    &mut self,
    kind: Kind,
    is_preopened: bool,
    name: String
) -> Result<Inode, __wasi_errno_t>
[src]

Creates an inode and inserts it given a Kind and some extra data

pub fn create_inode_with_default_stat(
    &mut self,
    kind: Kind,
    is_preopened: bool,
    name: String
) -> Inode
[src]

creates an inode and inserts it given a Kind, does not assume the file exists to

pub fn create_fd(
    &mut self,
    rights: __wasi_rights_t,
    rights_inheriting: __wasi_rights_t,
    flags: __wasi_fdflags_t,
    open_flags: u16,
    inode: Inode
) -> Result<__wasi_fd_t, __wasi_errno_t>
[src]

pub unsafe fn remove_inode(&mut self, inode: Inode) -> Option<InodeVal>[src]

This function is unsafe because it's the caller's responsibility to ensure that all refences to the given inode have been removed from the filesystem

returns true if the inode existed and was removed

pub fn get_stat_for_kind(&self, kind: &Kind) -> Option<__wasi_filestat_t>[src]

Trait Implementations

impl Debug for WasiFs[src]

impl<'de> Deserialize<'de> for WasiFs[src]

impl Serialize for WasiFs[src]

Auto Trait Implementations

impl !Sync for WasiFs

impl !Send for WasiFs

impl Unpin for WasiFs

impl !UnwindSafe for WasiFs

impl !RefUnwindSafe for WasiFs

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]

impl<T> Serialize for T where
    T: Serialize + ?Sized
[src]