Skip to main content

WasmModuleCompilation

Struct WasmModuleCompilation 

Source
pub struct WasmModuleCompilation(/* private fields */);
Expand description

An interface for asynchronous WebAssembly module compilation, to be used e.g. for implementing source phase imports.

Note: This interface is experimental and can change or be removed without notice.

Implementations§

Source§

impl WasmModuleCompilation

Source

pub fn new() -> Self

Start an asynchronous module compilation. This can be called on any thread.

Source

pub fn on_bytes_received(&mut self, data: &[u8])

Pass a new chunk of bytes to WebAssembly compilation. The buffer is owned by the caller and will not be accessed after this call returns. Can be called from any thread.

Source

pub fn finish( self, scope: &mut PinScope<'_, '_>, caching_callback: Option<unsafe extern "C" fn(*mut ModuleCachingInterface)>, resolution_callback: impl FnOnce(&Isolate, Result<Local<'_, WasmModuleObject>, Local<'_, Value>>) + 'static, )

Finish compilation. Must be called on the main thread after all bytes were passed to Self::on_bytes_received.

The resolution_callback will eventually be called with either the compiled module or a compilation error. The callback receives &Isolate so that crate::Global handles can be created from the Local handles to persist them beyond the callback.

Must not be called after Self::abort.

Source

pub fn abort(self)

Abort compilation. Can be called from any thread. Must not be called repeatedly, or after Self::finish.

Source

pub fn set_has_compiled_module_bytes(&mut self)

Mark that the embedder has (potentially) cached compiled module bytes (i.e. a serialized CompiledWasmModule) that could match this compilation request. This will cause V8 to skip streaming compilation. The embedder should then pass a caching callback to Self::finish.

Source

pub fn set_more_functions_can_be_serialized_callback( &mut self, callback: impl Fn(CompiledWasmModule) + Send + 'static, )

Sets a callback which is called whenever a significant number of new functions are ready for serialization.

Source

pub fn set_url(&mut self, url: &str)

Sets the UTF-8 encoded source URL for the Script object. This must be called before Self::finish.

Trait Implementations§

Source§

impl Default for WasmModuleCompilation

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for WasmModuleCompilation

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for WasmModuleCompilation

Auto Trait Implementations§

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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,