pub struct ModuleRegistry { /* private fields */ }Expand description
Process-global module registry. Holds every module that’s been
loaded so far, keyed by path. Two (require "lib/auth") calls
from different sites share one Module instance — the file is
loaded + evaluated exactly once.
Implementations§
Source§impl ModuleRegistry
impl ModuleRegistry
pub fn new() -> Self
Sourcepub fn get(&self, path: &str) -> Option<Module>
pub fn get(&self, path: &str) -> Option<Module>
Snapshot a loaded module. Returns None if not yet loaded.
Sourcepub fn begin_load(&self, path: &str) -> Result<(), ModuleError>
pub fn begin_load(&self, path: &str) -> Result<(), ModuleError>
Begin loading path. Pushes onto the load stack and returns
Err(Circular) if the path is already on the stack.
Sourcepub fn finish_load(&self, module: Module)
pub fn finish_load(&self, module: Module)
Finish loading path — remove from load stack, store final
module bindings.
Sourcepub fn abort_load(&self, path: &str)
pub fn abort_load(&self, path: &str)
Abort a load (e.g., after an error during eval). Drops the path from the load stack so retries can succeed.
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Clone for ModuleRegistry
impl Clone for ModuleRegistry
Source§fn clone(&self) -> ModuleRegistry
fn clone(&self) -> ModuleRegistry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ModuleRegistry
impl Debug for ModuleRegistry
Source§impl Default for ModuleRegistry
impl Default for ModuleRegistry
Source§fn default() -> ModuleRegistry
fn default() -> ModuleRegistry
Returns the “default value” for a type. Read more
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