Trait rhai::module_resolvers::ModuleResolver
source · [−]pub trait ModuleResolver: SendSync {
fn resolve(
&self,
engine: &Engine,
source: Option<&str>,
path: &str,
pos: Position
) -> Result<Shared<Module>, Box<EvalAltResult>>;
fn resolve_raw(
&self,
engine: &Engine,
global: &mut GlobalRuntimeState<'_>,
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
Provided methods
fn resolve_raw(
&self,
engine: &Engine,
global: &mut GlobalRuntimeState<'_>,
path: &str,
pos: Position
) -> Result<Shared<Module>, Box<EvalAltResult>>
fn resolve_raw(
&self,
engine: &Engine,
global: &mut GlobalRuntimeState<'_>,
path: &str,
pos: Position
) -> Result<Shared<Module>, Box<EvalAltResult>>
Resolve a module based on a path string, given a GlobalRuntimeState
.
WARNING - Low Level API
This function is very low level.
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.