Struct wasmer_wasi::WasiFs
source · [−]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 fs_backing: Box<dyn FileSystem>,
/* private fields */
}
Expand description
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
fs_backing: Box<dyn FileSystem>
Implementations
sourceimpl WasiFs
impl WasiFs
sourcepub fn stdout(&self) -> Result<&Option<Box<dyn VirtualFile>>, FsError>
pub fn stdout(&self) -> Result<&Option<Box<dyn VirtualFile>>, FsError>
Get the VirtualFile
object at stdout
sourcepub fn stdout_mut(
&mut self
) -> Result<&mut Option<Box<dyn VirtualFile>>, FsError>
pub fn stdout_mut(
&mut self
) -> Result<&mut Option<Box<dyn VirtualFile>>, FsError>
Get the VirtualFile
object at stdout mutably
sourcepub fn stderr(&self) -> Result<&Option<Box<dyn VirtualFile>>, FsError>
pub fn stderr(&self) -> Result<&Option<Box<dyn VirtualFile>>, FsError>
Get the VirtualFile
object at stderr
sourcepub fn stderr_mut(
&mut self
) -> Result<&mut Option<Box<dyn VirtualFile>>, FsError>
pub fn stderr_mut(
&mut self
) -> Result<&mut Option<Box<dyn VirtualFile>>, FsError>
Get the VirtualFile
object at stderr mutably
sourcepub fn stdin(&self) -> Result<&Option<Box<dyn VirtualFile>>, FsError>
pub fn stdin(&self) -> Result<&Option<Box<dyn VirtualFile>>, FsError>
Get the VirtualFile
object at stdin
sourcepub fn stdin_mut(
&mut self
) -> Result<&mut Option<Box<dyn VirtualFile>>, FsError>
pub fn stdin_mut(
&mut self
) -> Result<&mut Option<Box<dyn VirtualFile>>, FsError>
Get the VirtualFile
object at stdin mutably
sourcepub unsafe fn open_dir_all(
&mut self,
base: __wasi_fd_t,
name: String,
rights: __wasi_rights_t,
rights_inheriting: __wasi_rights_t,
flags: __wasi_fdflags_t
) -> Result<__wasi_fd_t, FsError>
pub unsafe fn open_dir_all(
&mut self,
base: __wasi_fd_t,
name: String,
rights: __wasi_rights_t,
rights_inheriting: __wasi_rights_t,
flags: __wasi_fdflags_t
) -> Result<__wasi_fd_t, FsError>
This function is like create dir all, but it also opens it. Function is unsafe because it may break invariants and hasn’t been tested. This is an experimental function and may be removed
Safety
- Virtual directories created with this function must not conflict with the standard operation of the WASI filesystem. This is vague and unlikely in pratice. Join the discussion for what the newer, safer WASI FS APIs should look like.
sourcepub fn open_file_at(
&mut self,
base: __wasi_fd_t,
file: Box<dyn VirtualFile>,
open_flags: u16,
name: String,
rights: __wasi_rights_t,
rights_inheriting: __wasi_rights_t,
flags: __wasi_fdflags_t
) -> Result<__wasi_fd_t, FsError>
pub fn open_file_at(
&mut self,
base: __wasi_fd_t,
file: Box<dyn VirtualFile>,
open_flags: u16,
name: String,
rights: __wasi_rights_t,
rights_inheriting: __wasi_rights_t,
flags: __wasi_fdflags_t
) -> Result<__wasi_fd_t, FsError>
Opens a user-supplied file in the directory specified with the name and flags given
sourcepub fn swap_file(
&mut self,
fd: __wasi_fd_t,
file: Box<dyn VirtualFile>
) -> Result<Option<Box<dyn VirtualFile>>, FsError>
pub fn swap_file(
&mut self,
fd: __wasi_fd_t,
file: Box<dyn VirtualFile>
) -> Result<Option<Box<dyn VirtualFile>>, FsError>
Change the backing of a given file descriptor Returns the old backing TODO: add examples
pub fn get_fd(&self, fd: __wasi_fd_t) -> Result<&Fd, __wasi_errno_t>
sourcepub fn get_inodeval_mut(
&mut self,
fd: __wasi_fd_t
) -> Result<&mut InodeVal, __wasi_errno_t>
pub fn get_inodeval_mut(
&mut self,
fd: __wasi_fd_t
) -> Result<&mut InodeVal, __wasi_errno_t>
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>
pub fn fdstat(&self, fd: __wasi_fd_t) -> Result<__wasi_fdstat_t, __wasi_errno_t>
pub fn prestat_fd(
&self,
fd: __wasi_fd_t
) -> Result<__wasi_prestat_t, __wasi_errno_t>
pub fn flush(&mut self, fd: __wasi_fd_t) -> Result<(), __wasi_errno_t>
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>
sourcepub unsafe fn remove_inode(&mut self, inode: Inode) -> Option<InodeVal>
pub unsafe fn remove_inode(&mut self, inode: Inode) -> Option<InodeVal>
Low level function to remove an inode, that is it deletes the WASI FS’s knowledge of a file.
This function returns the inode if it existed and was removed.
Safety
- The caller must ensure that all references to the specified inode have been removed from the filesystem.
pub fn get_stat_for_kind(&self, kind: &Kind) -> Option<__wasi_filestat_t>
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for WasiFs
impl Send for WasiFs
impl !Sync for WasiFs
impl Unpin for WasiFs
impl !UnwindSafe for WasiFs
Blanket Implementations
impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<F, W, T, D> Deserialize<With<T, W>, D> for F where
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for F where
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> Upcastable for T where
T: 'static + Any + Debug,
impl<T> Upcastable for T where
T: 'static + Any + Debug,
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_box(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more