wasmer_wasi

Struct WasiFs

Source
pub struct WasiFs {
    pub preopen_fds: RwLock<Vec<u32>>,
    pub name_map: HashMap<String, Inode>,
    pub fd_map: RwLock<HashMap<u32, Fd>>,
    pub next_fd: AtomicU32,
    pub current_dir: Mutex<String>,
    pub is_wasix: AtomicBool,
    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: RwLock<Vec<u32>>§name_map: HashMap<String, Inode>§fd_map: RwLock<HashMap<u32, Fd>>§next_fd: AtomicU32§current_dir: Mutex<String>§is_wasix: AtomicBool§fs_backing: Box<dyn FileSystem>

Implementations§

Source§

impl WasiFs

Source

pub unsafe fn open_dir_all( &mut self, inodes: &mut WasiInodes, base: WasiFd, name: String, rights: Rights, rights_inheriting: Rights, flags: Fdflags, ) -> Result<WasiFd, 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.
Source

pub fn open_file_at( &mut self, inodes: &mut WasiInodes, base: WasiFd, file: Box<dyn VirtualFile + Send + Sync + 'static>, open_flags: u16, name: String, rights: Rights, rights_inheriting: Rights, flags: Fdflags, ) -> Result<WasiFd, FsError>

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

Source

pub fn swap_file( &self, inodes: &WasiInodes, fd: WasiFd, file: Box<dyn VirtualFile + Send + Sync + 'static>, ) -> Result<Option<Box<dyn VirtualFile + Send + Sync + 'static>>, FsError>

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

Source

pub fn set_current_dir(&self, path: &str)

Changes the current directory

Source

pub fn get_current_dir( &self, inodes: &mut WasiInodes, base: WasiFd, ) -> Result<(Inode, String), Errno>

Gets the current directory

Source

pub fn get_fd(&self, fd: WasiFd) -> Result<Fd, Errno>

Source

pub fn get_fd_inode(&self, fd: WasiFd) -> Result<Index, Errno>

Source

pub fn filestat_fd( &self, inodes: &WasiInodes, fd: WasiFd, ) -> Result<Filestat, Errno>

Source

pub fn fdstat(&self, inodes: &WasiInodes, fd: WasiFd) -> Result<Fdstat, Errno>

Source

pub fn prestat_fd( &self, inodes: &WasiInodes, fd: WasiFd, ) -> Result<Prestat, Errno>

Source

pub fn flush(&self, inodes: &WasiInodes, fd: WasiFd) -> Result<(), Errno>

Source

pub fn create_fd( &self, rights: Rights, rights_inheriting: Rights, flags: Fdflags, open_flags: u16, inode: Inode, ) -> Result<WasiFd, Errno>

Source

pub fn clone_fd(&self, fd: WasiFd) -> Result<WasiFd, Errno>

Source

pub unsafe fn remove_inode( &self, inodes: &mut WasiInodes, 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.
Source

pub fn get_stat_for_kind( &self, inodes: &WasiInodes, kind: &Kind, ) -> Result<Filestat, Errno>

Trait Implementations§

Source§

impl Debug for WasiFs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for WasiFs

§

impl !RefUnwindSafe for WasiFs

§

impl Send for WasiFs

§

impl Sync for WasiFs

§

impl Unpin for WasiFs

§

impl !UnwindSafe for WasiFs

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcastable for T
where T: Any + Debug + 'static,

Source§

fn upcast_any_ref(&self) -> &(dyn Any + 'static)

Source§

fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)

Source§

fn upcast_any_box(self: Box<T>) -> Box<dyn Any>

Source§

impl<T> Upcastable for T
where T: Any + Send + Sync + 'static,

Source§

fn upcast_any_ref(&self) -> &(dyn Any + 'static)

upcast ref
Source§

fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)

upcast mut ref
Source§

fn upcast_any_box(self: Box<T>) -> Box<dyn Any>

upcast boxed dyn
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more