[−][src]Struct wasi_common::fs::Dir
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 WasiCtx, fd: Fd) -> 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]
&mut self,
path: P,
options: &OpenOptions
) -> Result<File>
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.
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Pointee for T[src]
type Pointer = u32
fn debug(
pointer: <T as Pointee>::Pointer,
f: &mut Formatter
) -> Result<(), Error>[src]
pointer: <T as Pointee>::Pointer,
f: &mut Formatter
) -> Result<(), Error>
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,