Struct deno_runtime::web_worker::WebWorker
source · pub struct WebWorker {
pub js_runtime: JsRuntime,
pub name: String,
pub worker_type: WebWorkerType,
pub main_module: ModuleSpecifier,
/* private fields */
}
Expand description
This struct is an implementation of Worker
Web API
Each WebWorker
is either a child of MainWorker
or other
WebWorker
.
Fields§
§js_runtime: JsRuntime
§name: String
§worker_type: WebWorkerType
§main_module: ModuleSpecifier
Implementations§
source§impl WebWorker
impl WebWorker
pub fn bootstrap_from_options(
name: String,
permissions: PermissionsContainer,
main_module: ModuleSpecifier,
worker_id: WorkerId,
options: WebWorkerOptions
) -> (Self, SendableWebWorkerHandle)
pub fn from_options(
name: String,
permissions: PermissionsContainer,
main_module: ModuleSpecifier,
worker_id: WorkerId,
options: WebWorkerOptions
) -> (Self, SendableWebWorkerHandle)
pub fn bootstrap(&mut self, options: &BootstrapOptions)
sourcepub async fn preload_main_module(
&mut self,
module_specifier: &ModuleSpecifier
) -> Result<ModuleId, AnyError>
pub async fn preload_main_module(
&mut self,
module_specifier: &ModuleSpecifier
) -> Result<ModuleId, AnyError>
Loads and instantiates specified JavaScript module as “main” module.
sourcepub async fn preload_side_module(
&mut self,
module_specifier: &ModuleSpecifier
) -> Result<ModuleId, AnyError>
pub async fn preload_side_module(
&mut self,
module_specifier: &ModuleSpecifier
) -> Result<ModuleId, AnyError>
Loads and instantiates specified JavaScript module as “side” module.
sourcepub async fn execute_side_module(
&mut self,
module_specifier: &ModuleSpecifier
) -> Result<(), AnyError>
pub async fn execute_side_module(
&mut self,
module_specifier: &ModuleSpecifier
) -> Result<(), AnyError>
Loads, instantiates and executes specified JavaScript module.
This method assumes that worker can’t be terminated when executing side module code.
sourcepub async fn execute_main_module(&mut self, id: ModuleId) -> Result<(), AnyError>
pub async fn execute_main_module(&mut self, id: ModuleId) -> Result<(), AnyError>
Loads, instantiates and executes specified JavaScript module.
This module will have “import.meta.main” equal to true.