use std::collections::HashMap;
use std::path::Path;
use std::sync::Arc;
use crate::module::ipc::protocol::{CliSpec, InvocationResultPayload};
use crate::module::traits::{EventType, ModuleError};
pub type WasmHostNodeCall =
std::sync::Arc<dyn Fn(&str, &str) -> Result<String, String> + Send + Sync>;
pub trait WasmModuleInstance: Send + Sync {
fn invoke_cli(
&self,
subcommand: &str,
args: Vec<String>,
) -> Result<InvocationResultPayload, ModuleError>;
fn invoke_rpc(
&self,
method: &str,
params: serde_json::Value,
) -> Result<serde_json::Value, ModuleError>;
fn cli_spec(&self) -> Option<CliSpec>;
fn event_types(&self) -> Result<Vec<EventType>, ModuleError>;
fn on_event(&self, event_json: &str) -> Result<String, ModuleError>;
fn last_on_event_result(&self) -> Option<String>;
fn set_host_node_call(&self, call: WasmHostNodeCall);
}
pub trait WasmModuleLoader: Send + Sync {
fn load(
&self,
path: &Path,
data_dir: &Path,
config: HashMap<String, String>,
) -> Result<Arc<dyn WasmModuleInstance>, String>;
}