Skip to main content

JsEngine

Trait JsEngine 

Source
pub trait JsEngine:
    Send
    + Sync
    + 'static {
    // Required methods
    fn eval(
        &self,
        source: &str,
        exchange: JsExchange,
    ) -> Result<JsEvalResult, JsLanguageError>;
    fn validate(&self, source: &str) -> Result<(), JsLanguageError>;
}
Expand description

Abstraction over a JavaScript engine capable of evaluating expressions against a JsExchange context.

Required Methods§

Source

fn eval( &self, source: &str, exchange: JsExchange, ) -> Result<JsEvalResult, JsLanguageError>

Evaluate source JavaScript code with the given exchange context.

Returns the result including the (potentially mutated) exchange state.

Source

fn validate(&self, source: &str) -> Result<(), JsLanguageError>

Validate that source is syntactically valid JavaScript without executing it.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§