pub struct ModuleRegistry { /* private fields */ }Expand description
Module registry for name resolution
Maintains a registry of all modules and their exported bindings, enabling both qualified and unqualified (via open) name lookups.
Implementations§
Source§impl ModuleRegistry
impl ModuleRegistry
Sourcepub fn with_stdlib() -> Self
pub fn with_stdlib() -> Self
Create a new module registry with standard library modules pre-registered
Sourcepub fn register_module(
&mut self,
name: String,
bindings: HashMap<String, Expr>,
types: HashMap<String, TypeDefinition>,
)
pub fn register_module( &mut self, name: String, bindings: HashMap<String, Expr>, types: HashMap<String, TypeDefinition>, )
Register a module with its bindings and types
§Arguments
name- Module namebindings- Map of value bindings (name -> expression)types- Map of type definitions (type name -> definition)
Sourcepub fn resolve_qualified(
&self,
module_name: &str,
binding_name: &str,
) -> Option<&Expr>
pub fn resolve_qualified( &self, module_name: &str, binding_name: &str, ) -> Option<&Expr>
Resolve a qualified name (e.g., “Math.add”)
§Returns
The expression bound to the qualified name, or None if not found.
Sourcepub fn get_module_bindings(
&self,
module_name: &str,
) -> Option<&HashMap<String, Expr>>
pub fn get_module_bindings( &self, module_name: &str, ) -> Option<&HashMap<String, Expr>>
Get all bindings from a module (for “open” imports)
§Returns
A reference to all bindings in the module, or None if module not found.
Sourcepub fn get_module_types(
&self,
module_name: &str,
) -> Option<&HashMap<String, TypeDefinition>>
pub fn get_module_types( &self, module_name: &str, ) -> Option<&HashMap<String, TypeDefinition>>
Get all type definitions from a module
§Returns
A reference to all type definitions in the module, or None if module not found.
Sourcepub fn has_module(&self, name: &str) -> bool
pub fn has_module(&self, name: &str) -> bool
Check if a module exists
Sourcepub fn get_module(&self, name: &str) -> Option<&Module>
pub fn get_module(&self, name: &str) -> Option<&Module>
Get a module by name
Sourcepub fn module_names(&self) -> Vec<&str>
pub fn module_names(&self) -> Vec<&str>
List all registered module names
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§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
Auto Trait Implementations§
impl Freeze for ModuleRegistry
impl RefUnwindSafe for ModuleRegistry
impl !Send for ModuleRegistry
impl !Sync for ModuleRegistry
impl Unpin for ModuleRegistry
impl UnwindSafe for ModuleRegistry
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)