Struct rhai::module_resolvers::ModuleResolversCollection
source · pub struct ModuleResolversCollection(/* private fields */);
Expand description
Module resolution service that holds a collection of module resolvers, to be searched in sequential order.
§Example
use rhai::{Engine, Module};
use rhai::module_resolvers::{StaticModuleResolver, ModuleResolversCollection};
let mut collection = ModuleResolversCollection::new();
let resolver = StaticModuleResolver::new();
collection.push(resolver);
let mut engine = Engine::new();
engine.set_module_resolver(collection);
Implementations§
source§impl ModuleResolversCollection
impl ModuleResolversCollection
sourcepub const fn new() -> Self
pub const fn new() -> Self
Create a new ModuleResolversCollection
.
§Example
use rhai::{Engine, Module};
use rhai::module_resolvers::{StaticModuleResolver, ModuleResolversCollection};
let mut collection = ModuleResolversCollection::new();
let resolver = StaticModuleResolver::new();
collection.push(resolver);
let mut engine = Engine::new();
engine.set_module_resolver(collection);
sourcepub fn push(&mut self, resolver: impl ModuleResolver + 'static) -> &mut Self
pub fn push(&mut self, resolver: impl ModuleResolver + 'static) -> &mut Self
Append a module resolver to the end.
sourcepub fn insert(
&mut self,
index: usize,
resolver: impl ModuleResolver + 'static
) -> &mut Self
pub fn insert( &mut self, index: usize, resolver: impl ModuleResolver + 'static ) -> &mut Self
sourcepub fn pop(&mut self) -> Option<Box<dyn ModuleResolver>>
pub fn pop(&mut self) -> Option<Box<dyn ModuleResolver>>
Remove the last module resolver from the end, if any.
sourcepub fn remove(&mut self, index: usize) -> Box<dyn ModuleResolver>
pub fn remove(&mut self, index: usize) -> Box<dyn ModuleResolver>
sourcepub fn iter(&self) -> impl Iterator<Item = &dyn ModuleResolver>
pub fn iter(&self) -> impl Iterator<Item = &dyn ModuleResolver>
Get an iterator of all the module resolvers.
sourcepub fn clear(&mut self) -> &mut Self
pub fn clear(&mut self) -> &mut Self
Remove all module resolvers.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if this ModuleResolversCollection
contains no module resolvers.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the number of module resolvers in this ModuleResolversCollection
.
sourcepub fn append(&mut self, other: Self) -> &mut Self
pub fn append(&mut self, other: Self) -> &mut Self
Add another ModuleResolversCollection
to the end of this collection.
The other ModuleResolversCollection
is consumed.
Trait Implementations§
source§impl<M: ModuleResolver + 'static> AddAssign<M> for ModuleResolversCollection
impl<M: ModuleResolver + 'static> AddAssign<M> for ModuleResolversCollection
source§fn add_assign(&mut self, rhs: M)
fn add_assign(&mut self, rhs: M)
Performs the
+=
operation. Read moresource§impl Default for ModuleResolversCollection
impl Default for ModuleResolversCollection
source§fn default() -> ModuleResolversCollection
fn default() -> ModuleResolversCollection
Returns the “default value” for a type. Read more
source§impl Extend<Box<dyn ModuleResolver>> for ModuleResolversCollection
impl Extend<Box<dyn ModuleResolver>> for ModuleResolversCollection
source§fn extend<T: IntoIterator<Item = Box<dyn ModuleResolver>>>(&mut self, iter: T)
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)
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)
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
source§impl<'a> IntoIterator for &'a ModuleResolversCollection
impl<'a> IntoIterator for &'a ModuleResolversCollection
source§impl ModuleResolver for ModuleResolversCollection
impl ModuleResolver for ModuleResolversCollection
source§fn resolve(
&self,
engine: &Engine,
source_path: Option<&str>,
path: &str,
pos: Position
) -> Result<Shared<Module>, Box<EvalAltResult>>
fn resolve( &self, engine: &Engine, source_path: Option<&str>, path: &str, pos: Position ) -> Result<Shared<Module>, Box<EvalAltResult>>
Resolve a module based on a path string.
source§fn resolve_raw(
&self,
engine: &Engine,
global: &mut GlobalRuntimeState,
scope: &mut Scope<'_>,
path: &str,
pos: Position
) -> Result<Shared<Module>, Box<EvalAltResult>>
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
. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ModuleResolversCollection
impl !Send for ModuleResolversCollection
impl !Sync for ModuleResolversCollection
impl Unpin for ModuleResolversCollection
impl !UnwindSafe for ModuleResolversCollection
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more