Maps a Rust function to an extern that WASM can expose to the Holochain host.
Annotate any compatible function with
#[hdk_extern] to expose it to Holochain as a WASM extern.
map_extern! ] macro is used internally by the
- Have a globally unique name
serde::Serialize + std::fmt::Debuginput
ExternResult) output where
O: serde::Serialize + std::fmt::Debug
This module only defines macros so check the HDK crate root to see more documentation.
A new extern function is created with the same name as the function with the
The new extern is placed in a child module of the current scope.
This new extern is hoisted by WASM to share a global namespace with all other externs so names must be globally unique even if the base function is scoped.
The new extern handles:
- Extern syntax for Rust
- Receiving the serialized bytes from the host at a memory pointer specified by the guest
- Setting the HDK wasm tracing subscriber as the global default
- Deserializing the input from the host
- Calling the function annotated with
- Serializing the result
- Converting the serialized result to a memory pointer for the host
- Error handling for all the above
If you want to do something different to the default you will need to understand and reimplement all the above.
Every extern must retern a