1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use crate::preview1::{WasiPreview1Adapter, WasiPreview1View};
use crate::{WasiCtx, WasiView};
use wasmtime::component::ResourceTable;

pub struct WasiP1Ctx {
    pub table: ResourceTable,
    pub wasi: WasiCtx,
    pub adapter: WasiPreview1Adapter,
}

impl WasiP1Ctx {
    pub fn new(wasi: WasiCtx) -> Self {
        Self {
            table: ResourceTable::new(),
            wasi,
            adapter: WasiPreview1Adapter::new(),
        }
    }
}

impl WasiView for WasiP1Ctx {
    fn table(&mut self) -> &mut ResourceTable {
        &mut self.table
    }
    fn ctx(&mut self) -> &mut WasiCtx {
        &mut self.wasi
    }
}

impl WasiPreview1View for WasiP1Ctx {
    fn adapter(&self) -> &WasiPreview1Adapter {
        &self.adapter
    }
    fn adapter_mut(&mut self) -> &mut WasiPreview1Adapter {
        &mut self.adapter
    }
}