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>
impl<const HAS_COMPILED_MODULE_BYTES: bool> WasmStreaming<HAS_COMPILED_MODULE_BYTES>
Sourcepub fn on_bytes_received(&mut self, data: &[u8])
pub fn on_bytes_received(&mut self, data: &[u8])
Pass a new chunk of bytes to WebAssembly streaming compilation.
Sourcepub fn abort(self, exception: Option<Local<'_, Value>>)
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.
Sourcepub fn set_url(&mut self, url: &str)
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>
impl WasmStreaming<false>
Sourcepub fn finish(self)
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.
Sourcepub fn set_has_compiled_module_bytes(self) -> WasmStreaming<true>
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>
impl WasmStreaming<true>
Sourcepub fn finish<F>(self, f: F)
pub fn finish<F>(self, f: F)
{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.