pub trait HostDescriptor {
Show 28 methods // Required methods fn read_via_stream( &mut self, self_: Resource<Descriptor>, offset: Filesize, ) -> Result<Resource<InputStream>, FsError>; fn write_via_stream( &mut self, self_: Resource<Descriptor>, offset: Filesize, ) -> Result<Resource<OutputStream>, FsError>; fn append_via_stream( &mut self, self_: Resource<Descriptor>, ) -> Result<Resource<OutputStream>, FsError>; fn advise<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, offset: Filesize, length: Filesize, advice: Advice, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn sync_data<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_flags<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<DescriptorFlags, FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_type<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<DescriptorType, FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_size<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, size: Filesize, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_times<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, data_access_timestamp: NewTimestamp, data_modification_timestamp: NewTimestamp, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn read<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, length: Filesize, offset: Filesize, ) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, bool), FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn write<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, buffer: Vec<u8>, offset: Filesize, ) -> Pin<Box<dyn Future<Output = Result<Filesize, FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn read_directory<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<Resource<DirectoryEntryStream>, FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn sync<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn create_directory_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path: String, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn stat<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<DescriptorStat, FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn stat_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path_flags: PathFlags, path: String, ) -> Pin<Box<dyn Future<Output = Result<DescriptorStat, FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_times_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path_flags: PathFlags, path: String, data_access_timestamp: NewTimestamp, data_modification_timestamp: NewTimestamp, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn link_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, old_path_flags: PathFlags, old_path: String, new_descriptor: Resource<Descriptor>, new_path: String, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn open_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path_flags: PathFlags, path: String, open_flags: OpenFlags, flags: DescriptorFlags, ) -> Pin<Box<dyn Future<Output = Result<Resource<Descriptor>, FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn readlink_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path: String, ) -> Pin<Box<dyn Future<Output = Result<String, FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn remove_directory_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path: String, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn rename_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, old_path: String, new_descriptor: Resource<Descriptor>, new_path: String, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn symlink_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, old_path: String, new_path: String, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn unlink_file_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path: String, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn is_same_object<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, other: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn metadata_hash<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<MetadataHashValue, FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn metadata_hash_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path_flags: PathFlags, path: String, ) -> Pin<Box<dyn Future<Output = Result<MetadataHashValue, FsError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn drop(&mut self, rep: Resource<Descriptor>) -> Result<()>;
}

Required Methods§

source

fn read_via_stream( &mut self, self_: Resource<Descriptor>, offset: Filesize, ) -> Result<Resource<InputStream>, FsError>

Return a stream for reading from a file, if available.

May fail with an error-code describing why the file cannot be read.

Multiple read, write, and append streams may be active on the same open file and they do not interfere with each other.

Note: This allows using read-stream, which is similar to read in POSIX.

source

fn write_via_stream( &mut self, self_: Resource<Descriptor>, offset: Filesize, ) -> Result<Resource<OutputStream>, FsError>

Return a stream for writing to a file, if available.

May fail with an error-code describing why the file cannot be written.

Note: This allows using write-stream, which is similar to write in POSIX.

source

fn append_via_stream( &mut self, self_: Resource<Descriptor>, ) -> Result<Resource<OutputStream>, FsError>

Return a stream for appending to a file, if available.

May fail with an error-code describing why the file cannot be appended.

Note: This allows using write-stream, which is similar to write with O_APPEND in in POSIX.

source

fn advise<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, offset: Filesize, length: Filesize, advice: Advice, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Provide file advisory information on a descriptor.

This is similar to posix_fadvise in POSIX.

source

fn sync_data<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Synchronize the data of a file to disk.

This function succeeds with no effect if the file descriptor is not opened for writing.

Note: This is similar to fdatasync in POSIX.

source

fn get_flags<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<DescriptorFlags, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get flags associated with a descriptor.

Note: This returns similar flags to fcntl(fd, F_GETFL) in POSIX.

Note: This returns the value that was the fs_flags value returned from fdstat_get in earlier versions of WASI.

source

fn get_type<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<DescriptorType, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the dynamic type of a descriptor.

Note: This returns the same value as the type field of the fd-stat returned by stat, stat-at and similar.

Note: This returns similar flags to the st_mode & S_IFMT value provided by fstat in POSIX.

Note: This returns the value that was the fs_filetype value returned from fdstat_get in earlier versions of WASI.

source

fn set_size<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, size: Filesize, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Adjust the size of an open file. If this increases the file’s size, the extra bytes are filled with zeros.

Note: This was called fd_filestat_set_size in earlier versions of WASI.

source

fn set_times<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, data_access_timestamp: NewTimestamp, data_modification_timestamp: NewTimestamp, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Adjust the timestamps of an open file or directory.

Note: This is similar to futimens in POSIX.

Note: This was called fd_filestat_set_times in earlier versions of WASI.

source

fn read<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, length: Filesize, offset: Filesize, ) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, bool), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Read from a descriptor, without using and updating the descriptor’s offset.

This function returns a list of bytes containing the data that was read, along with a bool which, when true, indicates that the end of the file was reached. The returned list will contain up to length bytes; it may return fewer than requested, if the end of the file is reached or if the I/O operation is interrupted.

In the future, this may change to return a stream<u8, error-code>.

Note: This is similar to pread in POSIX.

source

fn write<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, buffer: Vec<u8>, offset: Filesize, ) -> Pin<Box<dyn Future<Output = Result<Filesize, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Write to a descriptor, without using and updating the descriptor’s offset.

It is valid to write past the end of a file; the file is extended to the extent of the write, with bytes between the previous end and the start of the write set to zero.

In the future, this may change to take a stream<u8, error-code>.

Note: This is similar to pwrite in POSIX.

source

fn read_directory<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<Resource<DirectoryEntryStream>, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Read directory entries from a directory.

On filesystems where directories contain entries referring to themselves and their parents, often named . and .. respectively, these entries are omitted.

This always returns a new stream which starts at the beginning of the directory. Multiple streams may be active on the same directory, and they do not interfere with each other.

source

fn sync<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Synchronize the data and metadata of a file to disk.

This function succeeds with no effect if the file descriptor is not opened for writing.

Note: This is similar to fsync in POSIX.

source

fn create_directory_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path: String, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create a directory.

Note: This is similar to mkdirat in POSIX.

source

fn stat<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<DescriptorStat, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Return the attributes of an open file or directory.

Note: This is similar to fstat in POSIX, except that it does not return device and inode information. For testing whether two descriptors refer to the same underlying filesystem object, use is-same-object. To obtain additional data that can be used do determine whether a file has been modified, use metadata-hash.

Note: This was called fd_filestat_get in earlier versions of WASI.

source

fn stat_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path_flags: PathFlags, path: String, ) -> Pin<Box<dyn Future<Output = Result<DescriptorStat, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Return the attributes of a file or directory.

Note: This is similar to fstatat in POSIX, except that it does not return device and inode information. See the stat description for a discussion of alternatives.

Note: This was called path_filestat_get in earlier versions of WASI.

source

fn set_times_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path_flags: PathFlags, path: String, data_access_timestamp: NewTimestamp, data_modification_timestamp: NewTimestamp, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Adjust the timestamps of a file or directory.

Note: This is similar to utimensat in POSIX.

Note: This was called path_filestat_set_times in earlier versions of WASI.

Create a hard link.

Note: This is similar to linkat in POSIX.

source

fn open_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path_flags: PathFlags, path: String, open_flags: OpenFlags, flags: DescriptorFlags, ) -> Pin<Box<dyn Future<Output = Result<Resource<Descriptor>, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Open a file or directory.

The returned descriptor is not guaranteed to be the lowest-numbered descriptor not currently open/ it is randomized to prevent applications from depending on making assumptions about indexes, since this is error-prone in multi-threaded contexts. The returned descriptor is guaranteed to be less than 2**31.

If flags contains descriptor-flags::mutate-directory, and the base descriptor doesn’t have descriptor-flags::mutate-directory set, open-at fails with error-code::read-only.

If flags contains write or mutate-directory, or open-flags contains truncate or create, and the base descriptor doesn’t have descriptor-flags::mutate-directory set, open-at fails with error-code::read-only.

Note: This is similar to openat in POSIX.

Read the contents of a symbolic link.

If the contents contain an absolute or rooted path in the underlying filesystem, this function fails with error-code::not-permitted.

Note: This is similar to readlinkat in POSIX.

source

fn remove_directory_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path: String, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove a directory.

Return error-code::not-empty if the directory is not empty.

Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.

source

fn rename_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, old_path: String, new_descriptor: Resource<Descriptor>, new_path: String, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Rename a filesystem object.

Note: This is similar to renameat in POSIX.

Create a symbolic link (also known as a “symlink”).

If old-path starts with /, the function fails with error-code::not-permitted.

Note: This is similar to symlinkat in POSIX.

Unlink a filesystem object that is not a directory.

Return error-code::is-directory if the path refers to a directory. Note: This is similar to unlinkat(fd, path, 0) in POSIX.

source

fn is_same_object<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, other: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Test whether two descriptors refer to the same filesystem object.

In POSIX, this corresponds to testing whether the two descriptors have the same device (st_dev) and inode (st_ino or d_ino) numbers. wasi-filesystem does not expose device and inode numbers, so this function may be used instead.

source

fn metadata_hash<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<MetadataHashValue, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Return a hash of the metadata associated with a filesystem object referred to by a descriptor.

This returns a hash of the last-modification timestamp and file size, and may also include the inode number, device number, birth timestamp, and other metadata fields that may change when the file is modified or replaced. It may also include a secret value chosen by the implementation and not otherwise exposed.

Implementations are encourated to provide the following properties:

  • If the file is not modified or replaced, the computed hash value should usually not change.
  • If the object is modified or replaced, the computed hash value should usually change.
  • The inputs to the hash should not be easily computable from the computed hash.

However, none of these is required.

source

fn metadata_hash_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path_flags: PathFlags, path: String, ) -> Pin<Box<dyn Future<Output = Result<MetadataHashValue, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Return a hash of the metadata associated with a filesystem object referred to by a directory descriptor and a relative path.

This performs the same hash computation as metadata-hash.

source

fn drop(&mut self, rep: Resource<Descriptor>) -> Result<()>

Implementations on Foreign Types§

source§

impl<_T: HostDescriptor + ?Sized + Send> HostDescriptor for &mut _T

source§

fn read_via_stream( &mut self, self_: Resource<Descriptor>, offset: Filesize, ) -> Result<Resource<InputStream>, FsError>

Return a stream for reading from a file, if available.

May fail with an error-code describing why the file cannot be read.

Multiple read, write, and append streams may be active on the same open file and they do not interfere with each other.

Note: This allows using read-stream, which is similar to read in POSIX.

source§

fn write_via_stream( &mut self, self_: Resource<Descriptor>, offset: Filesize, ) -> Result<Resource<OutputStream>, FsError>

Return a stream for writing to a file, if available.

May fail with an error-code describing why the file cannot be written.

Note: This allows using write-stream, which is similar to write in POSIX.

source§

fn append_via_stream( &mut self, self_: Resource<Descriptor>, ) -> Result<Resource<OutputStream>, FsError>

Return a stream for appending to a file, if available.

May fail with an error-code describing why the file cannot be appended.

Note: This allows using write-stream, which is similar to write with O_APPEND in in POSIX.

source§

fn advise<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, offset: Filesize, length: Filesize, advice: Advice, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Provide file advisory information on a descriptor.

This is similar to posix_fadvise in POSIX.

source§

fn sync_data<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Synchronize the data of a file to disk.

This function succeeds with no effect if the file descriptor is not opened for writing.

Note: This is similar to fdatasync in POSIX.

source§

fn get_flags<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<DescriptorFlags, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get flags associated with a descriptor.

Note: This returns similar flags to fcntl(fd, F_GETFL) in POSIX.

Note: This returns the value that was the fs_flags value returned from fdstat_get in earlier versions of WASI.

source§

fn get_type<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<DescriptorType, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the dynamic type of a descriptor.

Note: This returns the same value as the type field of the fd-stat returned by stat, stat-at and similar.

Note: This returns similar flags to the st_mode & S_IFMT value provided by fstat in POSIX.

Note: This returns the value that was the fs_filetype value returned from fdstat_get in earlier versions of WASI.

source§

fn set_size<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, size: Filesize, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Adjust the size of an open file. If this increases the file’s size, the extra bytes are filled with zeros.

Note: This was called fd_filestat_set_size in earlier versions of WASI.

source§

fn set_times<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, data_access_timestamp: NewTimestamp, data_modification_timestamp: NewTimestamp, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Adjust the timestamps of an open file or directory.

Note: This is similar to futimens in POSIX.

Note: This was called fd_filestat_set_times in earlier versions of WASI.

source§

fn read<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, length: Filesize, offset: Filesize, ) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, bool), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Read from a descriptor, without using and updating the descriptor’s offset.

This function returns a list of bytes containing the data that was read, along with a bool which, when true, indicates that the end of the file was reached. The returned list will contain up to length bytes; it may return fewer than requested, if the end of the file is reached or if the I/O operation is interrupted.

In the future, this may change to return a stream<u8, error-code>.

Note: This is similar to pread in POSIX.

source§

fn write<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, buffer: Vec<u8>, offset: Filesize, ) -> Pin<Box<dyn Future<Output = Result<Filesize, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Write to a descriptor, without using and updating the descriptor’s offset.

It is valid to write past the end of a file; the file is extended to the extent of the write, with bytes between the previous end and the start of the write set to zero.

In the future, this may change to take a stream<u8, error-code>.

Note: This is similar to pwrite in POSIX.

source§

fn read_directory<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<Resource<DirectoryEntryStream>, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Read directory entries from a directory.

On filesystems where directories contain entries referring to themselves and their parents, often named . and .. respectively, these entries are omitted.

This always returns a new stream which starts at the beginning of the directory. Multiple streams may be active on the same directory, and they do not interfere with each other.

source§

fn sync<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Synchronize the data and metadata of a file to disk.

This function succeeds with no effect if the file descriptor is not opened for writing.

Note: This is similar to fsync in POSIX.

source§

fn create_directory_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path: String, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create a directory.

Note: This is similar to mkdirat in POSIX.

source§

fn stat<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<DescriptorStat, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Return the attributes of an open file or directory.

Note: This is similar to fstat in POSIX, except that it does not return device and inode information. For testing whether two descriptors refer to the same underlying filesystem object, use is-same-object. To obtain additional data that can be used do determine whether a file has been modified, use metadata-hash.

Note: This was called fd_filestat_get in earlier versions of WASI.

source§

fn stat_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path_flags: PathFlags, path: String, ) -> Pin<Box<dyn Future<Output = Result<DescriptorStat, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Return the attributes of a file or directory.

Note: This is similar to fstatat in POSIX, except that it does not return device and inode information. See the stat description for a discussion of alternatives.

Note: This was called path_filestat_get in earlier versions of WASI.

source§

fn set_times_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path_flags: PathFlags, path: String, data_access_timestamp: NewTimestamp, data_modification_timestamp: NewTimestamp, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Adjust the timestamps of a file or directory.

Note: This is similar to utimensat in POSIX.

Note: This was called path_filestat_set_times in earlier versions of WASI.

Create a hard link.

Note: This is similar to linkat in POSIX.

source§

fn open_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path_flags: PathFlags, path: String, open_flags: OpenFlags, flags: DescriptorFlags, ) -> Pin<Box<dyn Future<Output = Result<Resource<Descriptor>, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Open a file or directory.

The returned descriptor is not guaranteed to be the lowest-numbered descriptor not currently open/ it is randomized to prevent applications from depending on making assumptions about indexes, since this is error-prone in multi-threaded contexts. The returned descriptor is guaranteed to be less than 2**31.

If flags contains descriptor-flags::mutate-directory, and the base descriptor doesn’t have descriptor-flags::mutate-directory set, open-at fails with error-code::read-only.

If flags contains write or mutate-directory, or open-flags contains truncate or create, and the base descriptor doesn’t have descriptor-flags::mutate-directory set, open-at fails with error-code::read-only.

Note: This is similar to openat in POSIX.

Read the contents of a symbolic link.

If the contents contain an absolute or rooted path in the underlying filesystem, this function fails with error-code::not-permitted.

Note: This is similar to readlinkat in POSIX.

source§

fn remove_directory_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path: String, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove a directory.

Return error-code::not-empty if the directory is not empty.

Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.

source§

fn rename_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, old_path: String, new_descriptor: Resource<Descriptor>, new_path: String, ) -> Pin<Box<dyn Future<Output = Result<(), FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Rename a filesystem object.

Note: This is similar to renameat in POSIX.

Create a symbolic link (also known as a “symlink”).

If old-path starts with /, the function fails with error-code::not-permitted.

Note: This is similar to symlinkat in POSIX.

Unlink a filesystem object that is not a directory.

Return error-code::is-directory if the path refers to a directory. Note: This is similar to unlinkat(fd, path, 0) in POSIX.

source§

fn is_same_object<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, other: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Test whether two descriptors refer to the same filesystem object.

In POSIX, this corresponds to testing whether the two descriptors have the same device (st_dev) and inode (st_ino or d_ino) numbers. wasi-filesystem does not expose device and inode numbers, so this function may be used instead.

source§

fn metadata_hash<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, ) -> Pin<Box<dyn Future<Output = Result<MetadataHashValue, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Return a hash of the metadata associated with a filesystem object referred to by a descriptor.

This returns a hash of the last-modification timestamp and file size, and may also include the inode number, device number, birth timestamp, and other metadata fields that may change when the file is modified or replaced. It may also include a secret value chosen by the implementation and not otherwise exposed.

Implementations are encourated to provide the following properties:

  • If the file is not modified or replaced, the computed hash value should usually not change.
  • If the object is modified or replaced, the computed hash value should usually change.
  • The inputs to the hash should not be easily computable from the computed hash.

However, none of these is required.

source§

fn metadata_hash_at<'life0, 'async_trait>( &'life0 mut self, self_: Resource<Descriptor>, path_flags: PathFlags, path: String, ) -> Pin<Box<dyn Future<Output = Result<MetadataHashValue, FsError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Return a hash of the metadata associated with a filesystem object referred to by a directory descriptor and a relative path.

This performs the same hash computation as metadata-hash.

source§

fn drop(&mut self, rep: Resource<Descriptor>) -> Result<()>

Implementors§

source§

impl<T> HostDescriptor for WasiImpl<T>
where T: WasiView,