Skip to main content

WasmStreaming

Struct WasmStreaming 

Source
pub struct WasmStreaming<const HAS_COMPILED_MODULE_BYTES: bool>(/* private fields */);
Expand description

The V8 interface for WebAssembly streaming compilation. When streaming compilation is initiated, V8 passes a Self object to the embedder such that the embedder can pass the input bytes for streaming compilation to V8.

Implementations§

Source§

impl<const HAS_COMPILED_MODULE_BYTES: bool> WasmStreaming<HAS_COMPILED_MODULE_BYTES>

Source

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

Pass a new chunk of bytes to WebAssembly streaming compilation.

Source

pub fn abort(self, exception: Option<Local<'_, Value>>)

Abort streaming compilation. If {exception} has a value, then the promise associated with streaming compilation is rejected with that value. If {exception} does not have value, the promise does not get rejected.

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().

Source§

impl WasmStreaming<false>

Source

pub fn finish(self)

{Finish} should be called after all received bytes where passed to {OnBytesReceived} to tell V8 that there will be no more bytes. {Finish} must not be called after {Abort} has been called already. If {SetHasCompiledModuleBytes()} was called before, a {caching_callback} can be passed which can inspect the full received wire bytes and set cached module bytes which will be deserialized then. This callback will happen synchronously within this call; the callback is not stored.

Source

pub fn set_has_compiled_module_bytes(self) -> WasmStreaming<true>

Mark that the embedder has (potentially) cached compiled module bytes (i.e. a serialized {CompiledWasmModule}) that could match this streaming request. This will cause V8 to skip streaming compilation. The embedder should then pass a callback to the {Finish} method to pass the serialized bytes, after potentially checking their validity against the full received wire bytes.

Source§

impl WasmStreaming<true>

Source

pub fn finish<F>(self, f: F)
where F: MapFnTo<unsafe extern "C" fn(*mut ModuleCachingInterface)>,

{Finish} should be called after all received bytes where passed to {OnBytesReceived} to tell V8 that there will be no more bytes. {Finish} must not be called after {Abort} has been called already. If {SetHasCompiledModuleBytes()} was called before, a {caching_callback} can be passed which can inspect the full received wire bytes and set cached module bytes which will be deserialized then. This callback will happen synchronously within this call; the callback is not stored.

Trait Implementations§

Source§

impl<const HAS_COMPILED_MODULE_BYTES: bool> Drop for WasmStreaming<HAS_COMPILED_MODULE_BYTES>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<const HAS_COMPILED_MODULE_BYTES: bool> Freeze for WasmStreaming<HAS_COMPILED_MODULE_BYTES>

§

impl<const HAS_COMPILED_MODULE_BYTES: bool> RefUnwindSafe for WasmStreaming<HAS_COMPILED_MODULE_BYTES>

§

impl<const HAS_COMPILED_MODULE_BYTES: bool> !Send for WasmStreaming<HAS_COMPILED_MODULE_BYTES>

§

impl<const HAS_COMPILED_MODULE_BYTES: bool> !Sync for WasmStreaming<HAS_COMPILED_MODULE_BYTES>

§

impl<const HAS_COMPILED_MODULE_BYTES: bool> Unpin for WasmStreaming<HAS_COMPILED_MODULE_BYTES>

§

impl<const HAS_COMPILED_MODULE_BYTES: bool> UnsafeUnpin for WasmStreaming<HAS_COMPILED_MODULE_BYTES>

§

impl<const HAS_COMPILED_MODULE_BYTES: bool> UnwindSafe for WasmStreaming<HAS_COMPILED_MODULE_BYTES>

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,