Skip to main content

ModuleResolver

Trait ModuleResolver 

Source
pub trait ModuleResolver: SendSync {
    // Required method
    fn resolve(
        &self,
        engine: &Engine,
        source: Option<&str>,
        path: &str,
        pos: Position,
    ) -> Result<Shared<Module>, Box<EvalAltResult>>;

    // Provided methods
    fn resolve_raw(
        &self,
        engine: &Engine,
        global: &mut GlobalRuntimeState,
        scope: &mut Scope<'_>,
        path: &str,
        pos: Position,
    ) -> Result<Shared<Module>, Box<EvalAltResult>> { ... }
    fn resolve_ast(
        &self,
        engine: &Engine,
        source: Option<&str>,
        path: &str,
        pos: Position,
    ) -> Option<Result<AST, Box<EvalAltResult>>> { ... }
}
Expand description

Trait that encapsulates a module resolution service.

Required Methods§

Source

fn resolve( &self, engine: &Engine, source: Option<&str>, path: &str, pos: Position, ) -> Result<Shared<Module>, Box<EvalAltResult>>

Resolve a module based on a path string.

Provided Methods§

Source

fn resolve_raw( &self, engine: &Engine, global: &mut GlobalRuntimeState, scope: &mut Scope<'_>, path: &str, pos: Position, ) -> Result<Shared<Module>, Box<EvalAltResult>>

Resolve a module based on a path string, given a GlobalRuntimeState and the current Scope.

§WARNING - Low Level API

This function is very low level.

Source

fn resolve_ast( &self, engine: &Engine, source: Option<&str>, path: &str, pos: Position, ) -> Option<Result<AST, Box<EvalAltResult>>>

Resolve an AST based on a path string.

Returns None (default) if such resolution is not supported (e.g. if the module is Rust-based).

§WARNING - Low Level API

Override the default implementation of this method if the module resolver serves modules based on compiled Rhai scripts.

Trait Implementations§

Source§

impl Extend<Box<dyn ModuleResolver>> for ModuleResolversCollection

Source§

fn extend<T: IntoIterator<Item = Box<dyn ModuleResolver>>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§