pub struct VfsHostState {
pub wasi_ctx: WasiCtx,
pub table: ResourceTable,
pub shared_vfs: Arc<Fs>,
}Expand description
Host state that uses fs-core directly for filesystem operations.
Multiple instances can share the same VFS via Arc<Fs>.
Since fs-core uses DashMap internally with fine-grained locking,
no external lock is required. All Fs methods take &self.
Fields§
§wasi_ctx: WasiCtxWASI context for host operations (stdio, env, etc.)
table: ResourceTableResource table for managing WASM resources
Shared VFS: multiple VfsHostState instances can reference the same VFS No external lock needed - fs-core uses DashMap for internal thread safety
Implementations§
Source§impl VfsHostState
impl VfsHostState
Create a new VfsHostState that shares the same VFS core This enables multiple applications to access the same VFS concurrently
Create a new VfsHostState that shares the same VFS core with custom CLI arguments This enables passing arguments to WASM applications via WASI
Create a new VfsHostState that shares the same VFS core with custom environment variables This enables passing configuration to WASM handlers
Create a new VfsHostState from an existing shared VFS with custom environment variables This is useful when sharing VFS across threads (e.g., in HTTP server handlers)
Get the shared VFS for external use (e.g., sharing across threads)
Trait Implementations§
Source§impl Default for VfsHostState
impl Default for VfsHostState
Source§impl Host for VfsHostState
impl Host for VfsHostState
Source§fn get_directories(
&mut self,
) -> Result<Vec<(Resource<Descriptor>, String)>, Error>
fn get_directories( &mut self, ) -> Result<Vec<(Resource<Descriptor>, String)>, Error>
Source§impl Host for VfsHostState
impl Host for VfsHostState
Source§impl HostDescriptor for VfsHostState
impl HostDescriptor for VfsHostState
Source§fn read(
&mut self,
self_: Resource<Descriptor>,
len: u64,
offset: u64,
) -> Result<(Vec<u8>, bool), TrappableError<ErrorCode>>
fn read( &mut self, self_: Resource<Descriptor>, len: u64, offset: u64, ) -> Result<(Vec<u8>, bool), TrappableError<ErrorCode>>
Source§fn write(
&mut self,
self_: Resource<Descriptor>,
buffer: Vec<u8>,
offset: u64,
) -> Result<u64, TrappableError<ErrorCode>>
fn write( &mut self, self_: Resource<Descriptor>, buffer: Vec<u8>, offset: u64, ) -> Result<u64, TrappableError<ErrorCode>>
fn drop(&mut self, rep: Resource<Descriptor>) -> Result<(), Error>
Source§fn read_via_stream(
&mut self,
self_: Resource<Descriptor>,
offset: u64,
) -> Result<Resource<DynInputStream>, TrappableError<ErrorCode>>
fn read_via_stream( &mut self, self_: Resource<Descriptor>, offset: u64, ) -> Result<Resource<DynInputStream>, TrappableError<ErrorCode>>
Source§fn write_via_stream(
&mut self,
self_: Resource<Descriptor>,
offset: u64,
) -> Result<Resource<DynOutputStream>, TrappableError<ErrorCode>>
fn write_via_stream( &mut self, self_: Resource<Descriptor>, offset: u64, ) -> Result<Resource<DynOutputStream>, TrappableError<ErrorCode>>
Source§fn append_via_stream(
&mut self,
self_: Resource<Descriptor>,
) -> Result<Resource<DynOutputStream>, TrappableError<ErrorCode>>
fn append_via_stream( &mut self, self_: Resource<Descriptor>, ) -> Result<Resource<DynOutputStream>, TrappableError<ErrorCode>>
Source§fn advise(
&mut self,
_self_: Resource<Descriptor>,
_offset: u64,
_len: u64,
_advice: Advice,
) -> Result<(), TrappableError<ErrorCode>>
fn advise( &mut self, _self_: Resource<Descriptor>, _offset: u64, _len: u64, _advice: Advice, ) -> Result<(), TrappableError<ErrorCode>>
Source§fn sync_data(
&mut self,
_self_: Resource<Descriptor>,
) -> Result<(), TrappableError<ErrorCode>>
fn sync_data( &mut self, _self_: Resource<Descriptor>, ) -> Result<(), TrappableError<ErrorCode>>
Source§fn get_flags(
&mut self,
_self_: Resource<Descriptor>,
) -> Result<DescriptorFlags, TrappableError<ErrorCode>>
fn get_flags( &mut self, _self_: Resource<Descriptor>, ) -> Result<DescriptorFlags, TrappableError<ErrorCode>>
Source§fn get_type(
&mut self,
self_: Resource<Descriptor>,
) -> Result<DescriptorType, TrappableError<ErrorCode>>
fn get_type( &mut self, self_: Resource<Descriptor>, ) -> Result<DescriptorType, TrappableError<ErrorCode>>
Source§fn set_size(
&mut self,
self_: Resource<Descriptor>,
size: u64,
) -> Result<(), TrappableError<ErrorCode>>
fn set_size( &mut self, self_: Resource<Descriptor>, size: u64, ) -> Result<(), TrappableError<ErrorCode>>
Source§fn set_times(
&mut self,
_self_: Resource<Descriptor>,
_data_access_timestamp: NewTimestamp,
_data_modification_timestamp: NewTimestamp,
) -> Result<(), TrappableError<ErrorCode>>
fn set_times( &mut self, _self_: Resource<Descriptor>, _data_access_timestamp: NewTimestamp, _data_modification_timestamp: NewTimestamp, ) -> Result<(), TrappableError<ErrorCode>>
Source§fn set_times_at(
&mut self,
_self_: Resource<Descriptor>,
_path_flags: PathFlags,
_path: String,
_data_access_timestamp: NewTimestamp,
_data_modification_timestamp: NewTimestamp,
) -> Result<(), TrappableError<ErrorCode>>
fn set_times_at( &mut self, _self_: Resource<Descriptor>, _path_flags: PathFlags, _path: String, _data_access_timestamp: NewTimestamp, _data_modification_timestamp: NewTimestamp, ) -> Result<(), TrappableError<ErrorCode>>
Source§fn read_directory(
&mut self,
self_: Resource<Descriptor>,
) -> Result<Resource<DirectoryEntryStream>, TrappableError<ErrorCode>>
fn read_directory( &mut self, self_: Resource<Descriptor>, ) -> Result<Resource<DirectoryEntryStream>, TrappableError<ErrorCode>>
Source§fn sync(
&mut self,
_self_: Resource<Descriptor>,
) -> Result<(), TrappableError<ErrorCode>>
fn sync( &mut self, _self_: Resource<Descriptor>, ) -> Result<(), TrappableError<ErrorCode>>
Source§fn create_directory_at(
&mut self,
self_: Resource<Descriptor>,
path: String,
) -> Result<(), TrappableError<ErrorCode>>
fn create_directory_at( &mut self, self_: Resource<Descriptor>, path: String, ) -> Result<(), TrappableError<ErrorCode>>
Source§fn stat(
&mut self,
self_: Resource<Descriptor>,
) -> Result<DescriptorStat, TrappableError<ErrorCode>>
fn stat( &mut self, self_: Resource<Descriptor>, ) -> Result<DescriptorStat, TrappableError<ErrorCode>>
Source§fn stat_at(
&mut self,
self_: Resource<Descriptor>,
_path_flags: PathFlags,
path: String,
) -> Result<DescriptorStat, TrappableError<ErrorCode>>
fn stat_at( &mut self, self_: Resource<Descriptor>, _path_flags: PathFlags, path: String, ) -> Result<DescriptorStat, TrappableError<ErrorCode>>
Source§fn link_at(
&mut self,
_self_: Resource<Descriptor>,
_old_path_flags: PathFlags,
_old_path: String,
_new_descriptor: Resource<Descriptor>,
_new_path: String,
) -> Result<(), TrappableError<ErrorCode>>
fn link_at( &mut self, _self_: Resource<Descriptor>, _old_path_flags: PathFlags, _old_path: String, _new_descriptor: Resource<Descriptor>, _new_path: String, ) -> Result<(), TrappableError<ErrorCode>>
Source§fn open_at(
&mut self,
self_: Resource<Descriptor>,
_path_flags: PathFlags,
path: String,
open_flags: OpenFlags,
flags: DescriptorFlags,
) -> Result<Resource<Descriptor>, TrappableError<ErrorCode>>
fn open_at( &mut self, self_: Resource<Descriptor>, _path_flags: PathFlags, path: String, open_flags: OpenFlags, flags: DescriptorFlags, ) -> Result<Resource<Descriptor>, TrappableError<ErrorCode>>
Source§fn readlink_at(
&mut self,
_self_: Resource<Descriptor>,
_path: String,
) -> Result<String, TrappableError<ErrorCode>>
fn readlink_at( &mut self, _self_: Resource<Descriptor>, _path: String, ) -> Result<String, TrappableError<ErrorCode>>
Source§fn remove_directory_at(
&mut self,
self_: Resource<Descriptor>,
path: String,
) -> Result<(), TrappableError<ErrorCode>>
fn remove_directory_at( &mut self, self_: Resource<Descriptor>, path: String, ) -> Result<(), TrappableError<ErrorCode>>
Source§fn rename_at(
&mut self,
self_: Resource<Descriptor>,
old_path: String,
_new_descriptor: Resource<Descriptor>,
new_path: String,
) -> Result<(), TrappableError<ErrorCode>>
fn rename_at( &mut self, self_: Resource<Descriptor>, old_path: String, _new_descriptor: Resource<Descriptor>, new_path: String, ) -> Result<(), TrappableError<ErrorCode>>
Source§fn symlink_at(
&mut self,
_self_: Resource<Descriptor>,
_old_path: String,
_new_path: String,
) -> Result<(), TrappableError<ErrorCode>>
fn symlink_at( &mut self, _self_: Resource<Descriptor>, _old_path: String, _new_path: String, ) -> Result<(), TrappableError<ErrorCode>>
Source§fn unlink_file_at(
&mut self,
self_: Resource<Descriptor>,
path: String,
) -> Result<(), TrappableError<ErrorCode>>
fn unlink_file_at( &mut self, self_: Resource<Descriptor>, path: String, ) -> Result<(), TrappableError<ErrorCode>>
Source§fn is_same_object(
&mut self,
self_: Resource<Descriptor>,
other: Resource<Descriptor>,
) -> Result<bool, Error>
fn is_same_object( &mut self, self_: Resource<Descriptor>, other: Resource<Descriptor>, ) -> Result<bool, Error>
Source§fn metadata_hash(
&mut self,
self_: Resource<Descriptor>,
) -> Result<MetadataHashValue, TrappableError<ErrorCode>>
fn metadata_hash( &mut self, self_: Resource<Descriptor>, ) -> Result<MetadataHashValue, TrappableError<ErrorCode>>
Source§fn metadata_hash_at(
&mut self,
self_: Resource<Descriptor>,
_path_flags: PathFlags,
path: String,
) -> Result<MetadataHashValue, TrappableError<ErrorCode>>
fn metadata_hash_at( &mut self, self_: Resource<Descriptor>, _path_flags: PathFlags, path: String, ) -> Result<MetadataHashValue, TrappableError<ErrorCode>>
Source§impl HostDirectoryEntryStream for VfsHostState
impl HostDirectoryEntryStream for VfsHostState
Source§fn read_directory_entry(
&mut self,
self_: Resource<DirectoryEntryStream>,
) -> Result<Option<DirectoryEntry>, TrappableError<ErrorCode>>
fn read_directory_entry( &mut self, self_: Resource<DirectoryEntryStream>, ) -> Result<Option<DirectoryEntry>, TrappableError<ErrorCode>>
directory-entry-stream.fn drop(&mut self, rep: Resource<DirectoryEntryStream>) -> Result<(), Error>
Source§impl WasiView for VfsHostState
impl WasiView for VfsHostState
Source§fn ctx(&mut self) -> WasiCtxView<'_>
fn ctx(&mut self) -> WasiCtxView<'_>
WasiCtx configuration used for this
context.Auto Trait Implementations§
impl !RefUnwindSafe for VfsHostState
impl !Sync for VfsHostState
impl !UnwindSafe for VfsHostState
impl Freeze for VfsHostState
impl Send for VfsHostState
impl Unpin for VfsHostState
impl UnsafeUnpin for VfsHostState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more