wasmtime_wasi/
filesystem.rs1use crate::p2::filesystem::Dir;
2use wasmtime::component::{HasData, ResourceTable};
3
4pub(crate) struct WasiFilesystem;
5
6impl HasData for WasiFilesystem {
7 type Data<'a> = WasiFilesystemCtxView<'a>;
8}
9
10#[derive(Clone, Default)]
11pub struct WasiFilesystemCtx {
12 pub allow_blocking_current_thread: bool,
13 pub preopens: Vec<(Dir, String)>,
14}
15
16pub struct WasiFilesystemCtxView<'a> {
17 pub ctx: &'a mut WasiFilesystemCtx,
18 pub table: &'a mut ResourceTable,
19}
20
21pub trait WasiFilesystemView: Send {
22 fn filesystem(&mut self) -> WasiFilesystemCtxView<'_>;
23}
24
25bitflags::bitflags! {
26 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
27 pub struct FilePerms: usize {
28 const READ = 0b1;
29 const WRITE = 0b10;
30 }
31}
32
33bitflags::bitflags! {
34 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
35 pub struct OpenMode: usize {
36 const READ = 0b1;
37 const WRITE = 0b10;
38 }
39}
40
41bitflags::bitflags! {
42 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
47 pub struct DirPerms: usize {
48 const READ = 0b1;
51
52 const MUTATE = 0b10;
55 }
56}