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

source

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);
source

pub fn push(&mut self, resolver: impl ModuleResolver + 'static) -> &mut Self

Append a module resolver to the end.

source

pub fn insert( &mut self, index: usize, resolver: impl ModuleResolver + 'static ) -> &mut Self

Insert a module resolver to an offset index.

Panics

Panics if the index is out of bounds.

source

pub fn pop(&mut self) -> Option<Box<dyn ModuleResolver>>

Remove the last module resolver from the end, if any.

source

pub fn remove(&mut self, index: usize) -> Box<dyn ModuleResolver>

Remove a module resolver at an offset index.

Panics

Panics if the index is out of bounds.

source

pub fn iter(&self) -> impl Iterator<Item = &dyn ModuleResolver>

Get an iterator of all the module resolvers.

source

pub fn clear(&mut self) -> &mut Self

Remove all module resolvers.

source

pub fn is_empty(&self) -> bool

Returns true if this ModuleResolversCollection contains no module resolvers.

source

pub fn len(&self) -> usize

Get the number of module resolvers in this ModuleResolversCollection.

source

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

source§

fn add_assign(&mut self, rhs: M)

Performs the += operation. Read more
source§

impl Default for ModuleResolversCollection

source§

fn default() -> ModuleResolversCollection

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

impl Extend<Box<dyn ModuleResolver, Global>> 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
source§

impl<'a> IntoIterator for &'a ModuleResolversCollection

§

type Item = &'a Box<dyn ModuleResolver, Global>

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, Box<dyn ModuleResolver, Global>>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl IntoIterator for ModuleResolversCollection

§

type Item = Box<dyn ModuleResolver, Global>

The type of the elements being iterated over.
§

type IntoIter = IntoIter<[Box<dyn ModuleResolver, Global>; 3]>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl ModuleResolver for ModuleResolversCollection

source§

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>>

Resolve a module based on a path string, given a GlobalRuntimeState and the current Scope. Read more
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. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.