ModuleResolversCollection

Struct 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 quad_compat_rhai::{Engine, Module};
use quad_compat_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 fn new() -> Self

Create a new ModuleResolversCollection.

§Example
use quad_compat_rhai::{Engine, Module};
use quad_compat_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

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 IntoIterator for ModuleResolversCollection

Source§

type Item = Box<dyn ModuleResolver>

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<Box<dyn ModuleResolver>>

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_ast( &self, engine: &Engine, source_path: 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 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.