wasmtime_environ::component

Struct Translator

source
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>

source

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.

source

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.

Auto Trait Implementations§

§

impl<'a, 'data> Freeze for Translator<'a, 'data>

§

impl<'a, 'data> !RefUnwindSafe for Translator<'a, 'data>

§

impl<'a, 'data> !Send for Translator<'a, 'data>

§

impl<'a, 'data> !Sync for Translator<'a, 'data>

§

impl<'a, 'data> Unpin for Translator<'a, 'data>

§

impl<'a, 'data> !UnwindSafe for Translator<'a, 'data>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.