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.