DylibModuleResolver

Struct DylibModuleResolver 

Source
pub struct DylibModuleResolver { /* private fields */ }
Expand description

A module resolver that load dynamic libraries pointed by the import path.

Implementations§

Source§

impl DylibModuleResolver

Source

pub fn new() -> Self

Create a new instance of the resolver.

Source

pub fn enable_cache(&mut self, enable: bool) -> &mut Self

Enable/disable the cache.

Source

pub const fn is_cache_enabled(&self) -> bool

Is the cache enabled?

Source

pub fn with_path(path: impl Into<PathBuf>) -> Self

Create a new DylibModuleResolver with a specific base path.

§Example
use rhai::Engine;
use rhai_dylib::module_resolvers::libloading::DylibModuleResolver;

// Create a new 'DylibModuleResolver' loading dynamic libraries
// from the 'scripts' directory.
let resolver = DylibModuleResolver::with_path("./scripts");

let mut engine = Engine::new();
engine.set_module_resolver(resolver);
Source

pub fn get_file_path(&self, path: &str, source_path: Option<&Path>) -> PathBuf

Construct a full file path.

Trait Implementations§

Source§

impl Default for DylibModuleResolver

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl ModuleResolver for DylibModuleResolver

Source§

fn resolve_ast( &self, _: &Engine, _: Option<&str>, _: &str, _: Position, ) -> Option<Result<AST, Box<EvalAltResult>>>

This resolver is Rust based, so it cannot resolve ASTs. This function will always return None.

Source§

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

Resolve a module based on a path string.
Source§

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

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.