use std::sync::Arc;
use async_trait::async_trait;
use crate::{LixError, wasm::WasmLimits};
use super::{PluginCapabilities, contract::WasmComponentFactory};
pub mod v1 {
pub use crate::plugin::runtime::arena::{
Acceptance, Archive, ByteArena, ByteEdit, Digest, Error, FormatLayout, MapArena, Metrics,
PerformanceMeasurement, REQUIRED_V1_MEMORY_REDUCTION, REQUIRED_V1_SPEEDUP, Root,
StatePageLayout, Store, Transaction, compare_to_baseline,
};
}
#[async_trait]
pub trait WasmRuntime: Send + Sync {
async fn compile_component(
&self,
bytes: Vec<u8>,
limits: WasmLimits,
capabilities: PluginCapabilities,
) -> Result<Arc<dyn WasmComponentFactory>, LixError>;
}
#[derive(Debug, Default, Clone, Copy)]
pub struct UnsupportedWasmRuntime;
#[async_trait]
impl WasmRuntime for UnsupportedWasmRuntime {
async fn compile_component(
&self,
_bytes: Vec<u8>,
_limits: WasmLimits,
_capabilities: PluginCapabilities,
) -> Result<Arc<dyn WasmComponentFactory>, LixError> {
Err(LixError::new(
LixError::CODE_INTERNAL_ERROR,
"plugin execution requires a configured WASM component runtime",
))
}
}