use super::super::{super::store::*, library::*};
use {kutil::std::immutable::*, wasmtime_wasi::*};
pub struct PluginHost<StoreT>
where
StoreT: 'static + Store,
{
pub name: ByteString,
pub library: Library<StoreT>,
pub wasi: WasiCtx,
pub resources: ResourceTable,
}
impl<StoreT> PluginHost<StoreT>
where
StoreT: Store,
{
pub fn new(name: ByteString, library: Library<StoreT>) -> Self {
Self {
name,
library,
wasi: WasiCtxBuilder::new().inherit_stdout().inherit_stderr().build(),
resources: ResourceTable::default(),
}
}
}
impl<StoreT> WasiView for PluginHost<StoreT>
where
StoreT: 'static + Send + Store,
{
fn ctx(&mut self) -> WasiCtxView<'_> {
WasiCtxView { ctx: &mut self.wasi, table: &mut self.resources }
}
}