|
6 | 6 |
|
7 | 7 | #[cfg(feature = "wasmtime-host")] |
8 | 8 | mod impls { |
9 | | - // When enabling this feature, add real dependencies: |
10 | | - // wasmtime = { version = "*", features = ["component-model"] } |
11 | | - // wasmtime-wasi = "*" |
12 | | - // wit-bindgen = "*" (or cargo-component generated bindings) |
13 | | - |
14 | 9 | use super::*; |
| 10 | + use std::fs; |
15 | 11 | use std::path::Path; |
| 12 | + use wasmtime::component::{Component, Linker}; |
| 13 | + use wasmtime::{Config, Engine, Store}; |
| 14 | + |
| 15 | + // Minimal loader to validate component parsing. Host bindings come next. |
| 16 | + pub fn run_component(component_path: &Path, _core: CoreCtx) -> Result<(), String> { |
| 17 | + let mut cfg = Config::new(); |
| 18 | + cfg.wasm_component_model(true); |
| 19 | + |
| 20 | + let engine = Engine::new(&cfg).map_err(|e| e.to_string())?; |
| 21 | + if !component_path.exists() { |
| 22 | + return Err(format!("component not found: {}", component_path.display())); |
| 23 | + } |
| 24 | + |
| 25 | + // Basic read for clearer errors before Wasmtime parse |
| 26 | + let bytes = fs::read(component_path).map_err(|e| e.to_string())?; |
| 27 | + let _component = Component::from_binary(&engine, &bytes).map_err(|e| e.to_string())?; |
| 28 | + |
| 29 | + // Placeholder store and linker; no instantiation yet |
| 30 | + struct HostState; |
| 31 | + let mut store = Store::new(&engine, HostState); |
| 32 | + let _linker: Linker<HostState> = Linker::new(&engine); |
16 | 33 |
|
17 | | - pub fn run_component(_component_path: &Path, _ctx: CoreCtx) -> Result<(), String> { |
18 | | - // TODO: load component, instantiate with host shims for fs/net/log/time/rand, |
19 | | - // and drive the test app world entrypoints. |
20 | | - Err("wasmtime integration not implemented".to_string()) |
| 34 | + Err("component loaded; host bindings not implemented yet".to_string()) |
21 | 35 | } |
22 | 36 | } |
23 | 37 |
|
|
0 commit comments