Struct deno_runtime::worker::MainWorker
source · [−]pub struct MainWorker {
pub js_runtime: JsRuntime,
/* private fields */
}
Expand description
This worker is created and used by almost all subcommands in Deno executable.
It provides ops available in the Deno
namespace.
All WebWorker
s created during program execution
are descendants of this worker.
Fields
js_runtime: JsRuntime
Implementations
sourceimpl MainWorker
impl MainWorker
pub fn bootstrap_from_options(
main_module: ModuleSpecifier,
permissions: Permissions,
options: WorkerOptions
) -> Self
pub fn from_options(
main_module: ModuleSpecifier,
permissions: Permissions,
options: WorkerOptions
) -> Self
pub fn bootstrap(&mut self, options: &BootstrapOptions)
sourcepub fn execute_script(
&mut self,
script_name: &str,
source_code: &str
) -> Result<(), AnyError>
pub fn execute_script(
&mut self,
script_name: &str,
source_code: &str
) -> Result<(), AnyError>
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 evaluate_module(&mut self, id: ModuleId) -> Result<(), AnyError>
pub async fn evaluate_module(&mut self, id: ModuleId) -> Result<(), AnyError>
Executes specified JavaScript 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.
sourcepub async fn execute_main_module(
&mut self,
module_specifier: &ModuleSpecifier
) -> Result<(), AnyError>
pub async fn execute_main_module(
&mut self,
module_specifier: &ModuleSpecifier
) -> Result<(), AnyError>
Loads, instantiates and executes specified JavaScript module.
This module will have “import.meta.main” equal to true.
sourcepub async fn create_inspector_session(&mut self) -> LocalInspectorSession
pub async fn create_inspector_session(&mut self) -> LocalInspectorSession
Create new inspector session. This function panics if Worker was not configured to create inspector.
pub fn poll_event_loop(
&mut self,
cx: &mut Context<'_>,
wait_for_inspector: bool
) -> Poll<Result<(), AnyError>>
pub async fn run_event_loop(
&mut self,
wait_for_inspector: bool
) -> Result<(), AnyError>
sourcepub async fn with_event_loop<'a, T>(
&mut self,
fut: Pin<Box<dyn Future<Output = T> + 'a>>
) -> T
pub async fn with_event_loop<'a, T>(
&mut self,
fut: Pin<Box<dyn Future<Output = T> + 'a>>
) -> T
A utility function that runs provided future concurrently with the event loop.
Useful when using a local inspector session.
sourcepub fn get_exit_code(&self) -> i32
pub fn get_exit_code(&self) -> i32
Return exit code set by the executed code (either in main worker or one of child web workers).
sourcepub fn dispatch_load_event(&mut self, script_name: &str) -> Result<(), AnyError>
pub fn dispatch_load_event(&mut self, script_name: &str) -> Result<(), AnyError>
Dispatches “load” event to the JavaScript runtime.
Does not poll event loop, and thus not await any of the “load” event handlers.