use crate::component::{ComponentTranslation, ComponentTypesBuilder, TrampolineIndex};
use anyhow::Result;
use serde_derive::{Deserialize, Serialize};
use std::any::Any;
#[derive(Clone, Copy, Default, Serialize, Deserialize)]
pub struct AllCallFunc<T> {
pub wasm_call: T,
pub array_call: T,
pub native_call: T,
}
impl<T> AllCallFunc<T> {
pub fn map<U>(self, mut f: impl FnMut(T) -> U) -> AllCallFunc<U> {
AllCallFunc {
wasm_call: f(self.wasm_call),
array_call: f(self.array_call),
native_call: f(self.native_call),
}
}
}
pub trait ComponentCompiler: Send + Sync {
fn compile_trampoline(
&self,
component: &ComponentTranslation,
types: &ComponentTypesBuilder,
trampoline: TrampolineIndex,
) -> Result<AllCallFunc<Box<dyn Any + Send>>>;
}