pub struct Translator<'a, 'data> { /* private fields */ }
Expand description
Structure used to translate a component and parse it.
Implementations§
source§impl<'a, 'data> Translator<'a, 'data>
impl<'a, 'data> Translator<'a, 'data>
sourcepub fn new(
tunables: &'a Tunables,
validator: &'a mut Validator,
types: &'a mut ComponentTypesBuilder,
scope_vec: &'data ScopeVec<u8>,
) -> Self
pub fn new( tunables: &'a Tunables, validator: &'a mut Validator, types: &'a mut ComponentTypesBuilder, scope_vec: &'data ScopeVec<u8>, ) -> Self
Creates a new translation state ready to translate a component.
sourcepub fn translate(
self,
component: &'data [u8],
) -> Result<(ComponentTranslation, PrimaryMap<StaticModuleIndex, ModuleTranslation<'data>>)>
pub fn translate( self, component: &'data [u8], ) -> Result<(ComponentTranslation, PrimaryMap<StaticModuleIndex, ModuleTranslation<'data>>)>
Translates the binary component
.
This is the workhorse of compilation which will parse all of
component
and create type information for Wasmtime and such. The
component
does not have to be valid and it will be validated during
compilation.
The result of this function is a tuple of the final component’s
description plus a list of core wasm modules found within the
component. The component’s description actually erases internal
components, instances, etc, as much as it can. Instead Component
retains a flat list of initializers (no nesting) which was created
as part of compilation from the nested structure of the original
component.
The list of core wasm modules found is provided to allow compiling
modules externally in parallel. Additionally initializers in
Component
may refer to the modules in the map returned by index.
§Errors
This function will return an error if the component
provided is
invalid.