wasmer_wasix/runners/wcgi/
callbacks.rsuse std::{collections::HashMap, sync::Arc};
use virtual_fs::Pipe;
use wasmer::{Memory, Module, Store};
use super::{create_env::default_recycle_env, handler::SetupBuilder, *};
use crate::WasiEnv;
use wasmer_types::ModuleHash;
pub struct CreateEnvConfig {
pub env: HashMap<String, String>,
pub program_name: String,
pub module: Module,
pub module_hash: ModuleHash,
pub runtime: Arc<dyn crate::runtime::Runtime + Send + Sync>,
pub setup_builder: SetupBuilder,
}
pub struct CreateEnvResult {
pub env: WasiEnv,
pub memory: Option<(Memory, Store)>,
pub body_sender: Pipe,
pub body_receiver: Pipe,
pub stderr_receiver: Pipe,
}
pub struct RecycleEnvConfig {
pub env: WasiEnv,
pub memory: Memory,
pub store: Store,
}
#[async_trait::async_trait]
pub trait Callbacks: Send + Sync + 'static {
fn started(&self, _abort: AbortHandle) {}
fn on_stderr(&self, _stderr: &[u8]) {}
fn on_stderr_error(&self, _error: std::io::Error) {}
async fn recycle_env(&self, conf: RecycleEnvConfig) {
default_recycle_env(conf).await
}
async fn create_env(&self, conf: CreateEnvConfig) -> anyhow::Result<CreateEnvResult> {
default_create_env(conf).await
}
}
pub struct NoOpWcgiCallbacks;
impl Callbacks for NoOpWcgiCallbacks {}