pub trait ScriptEngine: Send {
// Required methods
fn init(&mut self, document: &mut BaseDocument);
fn execute(
&mut self,
code: &str,
language: ScriptLanguage,
context: &ExecutionContext,
) -> Result<ScriptValue, ScriptError>;
fn handle_event(&mut self, event: &DomEvent) -> EventHandled;
fn tick(&mut self) -> Result<bool, ScriptError>;
fn set_error_handler(&mut self, callback: Option<ScriptErrorCallback>);
}Expand description
Script engine trait - implement for Boa, V8, NanoVM, etc.
Required Methods§
Sourcefn init(&mut self, document: &mut BaseDocument)
fn init(&mut self, document: &mut BaseDocument)
Initialize the engine with a document
Sourcefn execute(
&mut self,
code: &str,
language: ScriptLanguage,
context: &ExecutionContext,
) -> Result<ScriptValue, ScriptError>
fn execute( &mut self, code: &str, language: ScriptLanguage, context: &ExecutionContext, ) -> Result<ScriptValue, ScriptError>
Execute code in the specified language
Sourcefn handle_event(&mut self, event: &DomEvent) -> EventHandled
fn handle_event(&mut self, event: &DomEvent) -> EventHandled
Handle a DOM event (keyboard, mouse, etc.) Returns whether the event was consumed
Sourcefn tick(&mut self) -> Result<bool, ScriptError>
fn tick(&mut self) -> Result<bool, ScriptError>
Poll for async work - called by document poll() Returns true if more work pending
Sourcefn set_error_handler(&mut self, callback: Option<ScriptErrorCallback>)
fn set_error_handler(&mut self, callback: Option<ScriptErrorCallback>)
Register an error callback
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".