[][src]Struct wasi_common::fs::Dir

pub struct Dir<'ctx> { /* fields omitted */ }

A reference to an open directory on the filesystem.

TODO: Implement Dir-using versions of std::fs's free functions: copy, create_dir, create_dir_all, hard_link, metadata, read_link, read_to_string, remove_dir, remove_dir_all, remove_file, rename, set_permissions, symlink_metadata, and write.

Unlike std::fs, this API has no canonicalize, because absolute paths don't interoperate well with the capability-oriented security model.

Methods

impl<'ctx> Dir<'ctx>[src]

pub unsafe fn from_raw_wasi_fd(ctx: &'ctx mut WasiCtx, fd: __wasi_fd_t) -> Self[src]

Constructs a new instance of Self from the given raw WASI file descriptor.

pub fn open_file<P: AsRef<Path>>(&mut self, path: P) -> Result<File>[src]

Attempts to open a file in read-only mode.

This corresponds to std::fs::File::open, but only accesses paths relative to and within self.

TODO: Not yet implemented. Refactor the hostcalls functions to split out the encoding/decoding parts from the underlying functionality, so that we can call into the underlying functionality directly.

pub fn open_file_with<P: AsRef<Path>>(
    &mut self,
    path: P,
    options: &OpenOptions
) -> Result<File>
[src]

Opens a file at path with the options specified by self.

This corresponds to std::fs::OpenOptions::open.

Instead of being a method on OpenOptions, this is a method on Dir, and it only accesses functions relative to and within self.

TODO: Not yet implemented.

pub fn open_dir<P: AsRef<Path>>(&mut self, path: P) -> Result<Self>[src]

Attempts to open a directory.

TODO: Not yet implemented. See the comment in open_file.

pub fn create_file<P: AsRef<Path>>(&mut self, path: P) -> Result<File>[src]

Opens a file in write-only mode.

This corresponds to std::fs::File::create, but only accesses paths relative to and within self.

TODO: Not yet implemented. See the comment in open_file.

pub fn read(&mut self) -> Result<ReadDir>[src]

Returns an iterator over the entries within a directory.

This corresponds to std::fs::read_dir, but reads the directory represented by self.

TODO: Not yet implemented. We may need to wait until we have the ability to duplicate file descriptors before we can implement read safely. For now, use into_read instead.

Important traits for ReadDir
pub fn into_read(self) -> ReadDir[src]

Consumes self and returns an iterator over the entries within a directory in the manner of read.

pub fn read_file<P: AsRef<Path>>(&mut self, path: P) -> Result<Vec<u8>>[src]

Read the entire contents of a file into a bytes vector.

This corresponds to std::fs::read, but only accesses paths relative to and within self.

pub fn read_dir<P: AsRef<Path>>(&mut self, path: P) -> Result<ReadDir>[src]

Returns an iterator over the entries within a directory.

This corresponds to std::fs::read_dir, but only accesses paths relative to and within self.

Trait Implementations

impl<'ctx> Drop for Dir<'ctx>[src]

Auto Trait Implementations

impl<'ctx> RefUnwindSafe for Dir<'ctx>

impl<'ctx> Send for Dir<'ctx>

impl<'ctx> Sync for Dir<'ctx>

impl<'ctx> Unpin for Dir<'ctx>

impl<'ctx> !UnwindSafe for Dir<'ctx>

Blanket Implementations

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

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

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

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

impl<T, U> Into<U> for T where
    U: From<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.