A Wasmtime component linker connects host capabilities to guest code: it registers the host implementation that the guest can call, then supports component instantiation. section 3.4.2
Connecting SmartCMS state
A Rust host enables the component model, creates an Engine and Store containing State, loads guest.wasm, and registers the kvstore interface. The generated add_to_linker function maps linker calls to state.key_value; the component can then be instantiated and its run function called. section 3.4.2
// ...
fn main() {
// ...
let mut linker = wasmtime::component::Linker::new(&engine);
component::smartcms::kvstore::add_to_linker
➥(&mut linker, |state: &mut State| &mut state.key_value).unwrap();
}
Inspect the central registration call that connects generated kvstore bindings to the host's mutable KeyValue state. section 3.4.2
