pub struct ModuleRegistry { /* private fields */ }Expand description
Maintains the full module graph with circular-dependency detection.
Implementations§
Source§impl ModuleRegistry
impl ModuleRegistry
pub fn new(loader: Box<dyn ModuleLoader>) -> Self
pub fn with_string_map(map: HashMap<String, String>) -> Self
Sourcepub fn require(&mut self, path: &str, vm: &mut Vm) -> Result<Value, ScriptError>
pub fn require(&mut self, path: &str, vm: &mut Vm) -> Result<Value, ScriptError>
require(path, vm) — load, compile and execute a module; cache result.
Sourcepub fn reload(&mut self, path: &str, vm: &mut Vm) -> Result<Value, ScriptError>
pub fn reload(&mut self, path: &str, vm: &mut Vm) -> Result<Value, ScriptError>
Reload a module by path (re-compile and re-execute).
Sourcepub fn loaded_modules(&self) -> Vec<String>
pub fn loaded_modules(&self) -> Vec<String>
List all loaded module names.
pub fn get_module(&self, path: &str) -> Option<&Module>
Sourcepub fn dependency_tree(&self, path: &str) -> String
pub fn dependency_tree(&self, path: &str) -> String
ASCII-art dependency tree for a module.
Auto Trait Implementations§
impl Freeze for ModuleRegistry
impl !RefUnwindSafe for ModuleRegistry
impl !Send for ModuleRegistry
impl !Sync for ModuleRegistry
impl Unpin for ModuleRegistry
impl UnsafeUnpin for ModuleRegistry
impl !UnwindSafe for ModuleRegistry
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.