Skip to main content

ModuleRegistry

Struct ModuleRegistry 

Source
pub struct ModuleRegistry { /* private fields */ }
Expand description

Module registry for managing multiple modules.

Implementations§

Source§

impl ModuleRegistry

Source

pub fn new() -> Self

Create a new module registry.

Source

pub fn register(&mut self, module: Module) -> Result<(), String>

Register a module.

Source

pub fn get(&self, path: &str) -> Option<&Module>

Get a module by path.

Source

pub fn all_modules(&self) -> Vec<&Module>

Get all registered modules.

Source

pub fn contains(&self, path: &str) -> bool

Check if a module is registered.

Source

pub fn get_mut(&mut self, path: &str) -> Option<&mut Module>

Get a mutable reference to a module by path.

Source

pub fn unregister(&mut self, path: &str) -> Option<Module>

Remove and return a module from the registry.

Source

pub fn resolve(&self, from: &str, name: &str) -> ResolvedName

Resolve a name from the perspective of a given module.

Checks the module’s local declarations first, then searches through its imports using import specifications.

Source

pub fn dependency_order(&self) -> Result<Vec<String>, Vec<String>>

Compute a topological sort of modules based on their dependencies.

Returns Ok(order) with module names in dependency order (dependencies first), or Err(cycle) with the names of modules involved in a cycle.

Source

pub fn detect_cycles(&self) -> Vec<Vec<String>>

Detect cycles in the module dependency graph.

Returns a list of cycles, where each cycle is a list of module names.

Source

pub fn transitive_deps(&self, module: &str) -> Vec<String>

Get all transitive dependencies of a module.

Source

pub fn detect_mutual_imports(&self) -> Vec<(String, String)>

Detect mutual (cyclic) imports between modules.

Source

pub fn are_mutually_dependent(&self, a: &str, b: &str) -> bool

Check if two modules import each other.

Source

pub fn get_dependents(&self, module_name: &str) -> Vec<String>

Get all modules that depend on a given module.

Source

pub fn get_all_dependencies(&self, module_name: &str) -> Vec<String>

Get all modules that a given module depends on (indirect + direct).

Source

pub fn verify_consistency(&self) -> Result<(), Vec<String>>

Verify module consistency (no broken imports).

Source

pub fn get_reverse_dependencies(&self, module_name: &str) -> Vec<String>

Get all modules that would be transitively affected by changes to a module.

Source

pub fn reachable_from(&self, module_name: &str) -> Vec<String>

Reachability analysis: which modules can be reached from a given module.

Source

pub fn get_sccs(&self) -> Vec<Vec<String>>

Get module strongly connected components (for circular dependency analysis).

Source

pub fn get_statistics(&self) -> HashMap<String, usize>

Get import statistics for debugging.

Source

pub fn get_public_interface(&self, module_name: &str) -> Vec<String>

Export a module’s public interface.

Source

pub fn is_name_accessible( &self, name: &str, from_module: &str, to_module: &str, ) -> bool

Check if name is accessible from module A in module B.

Trait Implementations§

Source§

impl Default for ModuleRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. 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.