wit_component::metadata

Function decode

Source
pub fn decode(wasm: &[u8]) -> Result<(Option<Vec<u8>>, Bindgen)>
Expand description

This function will parse the core wasm binary given as input and return a Bindgen which extracts the custom sections describing component-level types from within the binary itself.

This is used to parse the output of wit-bindgen-generated modules and is one of the earliest phases in transitioning such a module to a component. The extraction here provides the metadata necessary to continue the process later on.

This will return an error if wasm is not a valid WebAssembly module.

If a component-type custom section was found then a new binary is optionally returned with the custom sections stripped out. If no component-type custom sections are found then None is returned.