wasmtime_environ/
hostcall.rs1#[cfg(feature = "component-model")]
2use crate::component::ComponentBuiltinFunctionIndex;
3use crate::BuiltinFunctionIndex;
4
5pub enum HostCall {
12 ArrayCall,
15
16 Builtin(BuiltinFunctionIndex),
19
20 #[cfg(feature = "component-model")]
26 ComponentLowerImport,
27
28 #[cfg(feature = "component-model")]
31 ComponentBuiltin(ComponentBuiltinFunctionIndex),
32}
33
34impl HostCall {
35 pub const fn index(&self) -> u32 {
37 match self {
38 HostCall::ArrayCall => 0,
39 HostCall::Builtin(i) => 1 + i.index(),
40 #[cfg(feature = "component-model")]
41 HostCall::ComponentLowerImport => 1 + BuiltinFunctionIndex::len(),
42 #[cfg(feature = "component-model")]
43 HostCall::ComponentBuiltin(i) => 2 + BuiltinFunctionIndex::len() + i.index(),
44 }
45 }
46}
47
48impl From<BuiltinFunctionIndex> for HostCall {
49 fn from(idx: BuiltinFunctionIndex) -> HostCall {
50 HostCall::Builtin(idx)
51 }
52}
53
54#[cfg(feature = "component-model")]
55impl From<ComponentBuiltinFunctionIndex> for HostCall {
56 fn from(idx: ComponentBuiltinFunctionIndex) -> HostCall {
57 HostCall::ComponentBuiltin(idx)
58 }
59}