Struct rhai::module_resolvers::StaticModuleResolver
source · [−]pub struct StaticModuleResolver(_);
Expand description
A static module resolution service that serves modules added into it.
Example
use rhai::{Engine, Module};
use rhai::module_resolvers::StaticModuleResolver;
let mut resolver = StaticModuleResolver::new();
let module = Module::new();
resolver.insert("hello", module);
let mut engine = Engine::new();
engine.set_module_resolver(resolver);
Implementations
sourceimpl StaticModuleResolver
impl StaticModuleResolver
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new StaticModuleResolver
.
Example
use rhai::{Engine, Module};
use rhai::module_resolvers::StaticModuleResolver;
let mut resolver = StaticModuleResolver::new();
let module = Module::new();
resolver.insert("hello", module);
let mut engine = Engine::new();
engine.set_module_resolver(resolver);
sourcepub fn insert(&mut self, path: impl Into<Identifier>, module: Module)
pub fn insert(&mut self, path: impl Into<Identifier>, module: Module)
Add a module keyed by its path.
sourcepub fn contains_path(&self, path: &str) -> bool
pub fn contains_path(&self, path: &str) -> bool
Does the path exist?
sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &Shared<Module>)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &Shared<Module>)>
Get an iterator of all the modules.
sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = (&str, &mut Shared<Module>)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&str, &mut Shared<Module>)>
Get a mutable iterator of all the modules.
sourcepub fn values(&self) -> impl Iterator<Item = &Shared<Module>>
pub fn values(&self) -> impl Iterator<Item = &Shared<Module>>
Get an iterator of all the modules.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Is this StaticModuleResolver
empty?
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the number of modules in this StaticModuleResolver
.
sourcepub fn merge(&mut self, other: Self) -> &mut Self
pub fn merge(&mut self, other: Self) -> &mut Self
Merge another StaticModuleResolver
into this.
The other StaticModuleResolver
is consumed.
Existing modules of the same path name are overwritten.
Trait Implementations
sourceimpl AddAssign<StaticModuleResolver> for StaticModuleResolver
impl AddAssign<StaticModuleResolver> for StaticModuleResolver
sourcefn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the +=
operation. Read more
sourceimpl Clone for StaticModuleResolver
impl Clone for StaticModuleResolver
sourcefn clone(&self) -> StaticModuleResolver
fn clone(&self) -> StaticModuleResolver
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for StaticModuleResolver
impl Debug for StaticModuleResolver
sourceimpl Default for StaticModuleResolver
impl Default for StaticModuleResolver
sourcefn default() -> StaticModuleResolver
fn default() -> StaticModuleResolver
Returns the “default value” for a type. Read more
sourceimpl IntoIterator for StaticModuleResolver
impl IntoIterator for StaticModuleResolver
type Item = (SmartString<LazyCompact>, Rc<Module>)
type Item = (SmartString<LazyCompact>, Rc<Module>)
The type of the elements being iterated over.
type IntoIter = IntoIter<SmartString<LazyCompact>, Rc<Module>>
type IntoIter = IntoIter<SmartString<LazyCompact>, Rc<Module>>
Which kind of iterator are we turning this into?
sourceimpl ModuleResolver for StaticModuleResolver
impl ModuleResolver for StaticModuleResolver
sourcefn resolve(
&self,
_: &Engine,
_: Option<&str>,
path: &str,
pos: Position
) -> Result<Shared<Module>, Box<EvalAltResult>>
fn resolve(
&self,
_: &Engine,
_: Option<&str>,
path: &str,
pos: Position
) -> Result<Shared<Module>, Box<EvalAltResult>>
Resolve a module based on a path string.
sourcefn 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
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for StaticModuleResolver
impl !Send for StaticModuleResolver
impl !Sync for StaticModuleResolver
impl Unpin for StaticModuleResolver
impl !UnwindSafe for StaticModuleResolver
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more