use zerolaunch_plugin_protocol::{codes, JsonRpcError};
#[async_trait::async_trait]
pub trait HostCallHandler: Send + Sync {
async fn handle_host_call(
&self,
method: &str,
params: serde_json::Value,
) -> Result<serde_json::Value, JsonRpcError>;
}
impl std::fmt::Debug for dyn HostCallHandler {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "HostCallHandler")
}
}
pub fn method_not_found(method: &str) -> JsonRpcError {
JsonRpcError::new(
codes::METHOD_NOT_FOUND,
format!("host method not found: {}", method),
)
}
pub fn invalid_params(msg: impl Into<String>) -> JsonRpcError {
JsonRpcError::new(codes::INVALID_PARAMS, msg)
}