pub struct EcosystemRegistry { /* private fields */ }Expand description
Registry for all available ecosystems.
This registry manages ecosystem implementations and provides fast lookup by ecosystem ID or manifest filename. It’s designed for thread-safe concurrent access using DashMap.
§Examples
use deps_core::EcosystemRegistry;
use std::sync::Arc;
let registry = EcosystemRegistry::new();
// Register ecosystems (would be actual implementations)
// registry.register(Arc::new(CargoEcosystem::new(cache.clone())));
// registry.register(Arc::new(NpmEcosystem::new(cache.clone())));
// Look up by filename
if let Some(ecosystem) = registry.get_for_filename("Cargo.toml") {
println!("Found ecosystem: {}", ecosystem.display_name());
}
// List all registered ecosystems
for id in registry.ecosystem_ids() {
println!("Registered: {}", id);
}Implementations§
Source§impl EcosystemRegistry
impl EcosystemRegistry
Sourcepub fn new() -> EcosystemRegistry
pub fn new() -> EcosystemRegistry
Create a new empty registry
§Examples
use deps_core::EcosystemRegistry;
let registry = EcosystemRegistry::new();
assert_eq!(registry.ecosystem_ids().len(), 0);Sourcepub fn register(&self, ecosystem: Arc<dyn Ecosystem>)
pub fn register(&self, ecosystem: Arc<dyn Ecosystem>)
Register an ecosystem implementation
This method registers the ecosystem and creates filename mappings for all manifest filenames declared by the ecosystem.
§Arguments
ecosystem- Arc-wrapped ecosystem implementation
§Examples
use deps_core::EcosystemRegistry;
use std::sync::Arc;
let registry = EcosystemRegistry::new();
// registry.register(Arc::new(CargoEcosystem::new(cache)));Sourcepub fn get(&self, id: &str) -> Option<Arc<dyn Ecosystem>>
pub fn get(&self, id: &str) -> Option<Arc<dyn Ecosystem>>
Get ecosystem by ID
§Arguments
id- Ecosystem identifier (e.g., “cargo”, “npm”, “pypi”)
§Returns
Some(Arc<dyn Ecosystem>)- Registered ecosystemNone- No ecosystem registered with this ID
§Examples
use deps_core::EcosystemRegistry;
let registry = EcosystemRegistry::new();
if let Some(ecosystem) = registry.get("cargo") {
println!("Found: {}", ecosystem.display_name());
}Sourcepub fn get_for_filename(&self, filename: &str) -> Option<Arc<dyn Ecosystem>>
pub fn get_for_filename(&self, filename: &str) -> Option<Arc<dyn Ecosystem>>
Get ecosystem for a filename
§Arguments
filename- Manifest filename (e.g., “Cargo.toml”, “package.json”)
§Returns
Some(Arc<dyn Ecosystem>)- Ecosystem handling this filenameNone- No ecosystem handles this filename
§Examples
use deps_core::EcosystemRegistry;
let registry = EcosystemRegistry::new();
if let Some(ecosystem) = registry.get_for_filename("Cargo.toml") {
println!("Cargo.toml handled by: {}", ecosystem.display_name());
}Sourcepub fn get_for_uri(&self, uri: &Uri) -> Option<Arc<dyn Ecosystem>>
pub fn get_for_uri(&self, uri: &Uri) -> Option<Arc<dyn Ecosystem>>
Get ecosystem from URI
Extracts the filename from the URI path and looks up the ecosystem.
§Arguments
uri- Document URI (file:///path/to/Cargo.toml)
§Returns
Some(Arc<dyn Ecosystem>)- Ecosystem handling this fileNone- No ecosystem handles this file type or URI parsing failed
§Examples
use deps_core::EcosystemRegistry;
use tower_lsp_server::ls_types::Uri;
let registry = EcosystemRegistry::new();
let uri = Uri::from_file_path("/home/user/project/Cargo.toml").unwrap();
if let Some(ecosystem) = registry.get_for_uri(&uri) {
println!("File handled by: {}", ecosystem.display_name());
}Sourcepub fn ecosystem_ids(&self) -> Vec<&'static str>
pub fn ecosystem_ids(&self) -> Vec<&'static str>
Get all registered ecosystem IDs
Returns a vector of all ecosystem IDs currently registered. This is useful for debugging and listing available ecosystems.
§Returns
Vector of ecosystem ID strings
§Examples
use deps_core::EcosystemRegistry;
let registry = EcosystemRegistry::new();
// registry.register(cargo_ecosystem);
// registry.register(npm_ecosystem);
for id in registry.ecosystem_ids() {
println!("Registered ecosystem: {}", id);
}Sourcepub fn get_for_lockfile(&self, filename: &str) -> Option<Arc<dyn Ecosystem>>
pub fn get_for_lockfile(&self, filename: &str) -> Option<Arc<dyn Ecosystem>>
Get ecosystem for a lock file name
§Arguments
filename- Lock file name (e.g., “Cargo.lock”, “package-lock.json”)
§Returns
Some(Arc<dyn Ecosystem>)- Ecosystem using this lock fileNone- No ecosystem uses this lock file
§Examples
use deps_core::EcosystemRegistry;
let registry = EcosystemRegistry::new();
// registry.register(cargo_ecosystem);
if let Some(ecosystem) = registry.get_for_lockfile("Cargo.lock") {
println!("Cargo.lock handled by: {}", ecosystem.display_name());
}Sourcepub fn all_lockfile_patterns(&self) -> Vec<String>
pub fn all_lockfile_patterns(&self) -> Vec<String>
Get all lock file patterns for file watching
Returns glob patterns (e.g., “**/Cargo.lock”) for all registered ecosystems.
§Examples
use deps_core::EcosystemRegistry;
let registry = EcosystemRegistry::new();
// registry.register(cargo_ecosystem);
// registry.register(npm_ecosystem);
let patterns = registry.all_lockfile_patterns();
for pattern in patterns {
println!("Watching pattern: {}", pattern);
}Trait Implementations§
Source§impl Default for EcosystemRegistry
impl Default for EcosystemRegistry
Source§fn default() -> EcosystemRegistry
fn default() -> EcosystemRegistry
Auto Trait Implementations§
impl Freeze for EcosystemRegistry
impl !RefUnwindSafe for EcosystemRegistry
impl Send for EcosystemRegistry
impl Sync for EcosystemRegistry
impl Unpin for EcosystemRegistry
impl !UnwindSafe for EcosystemRegistry
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more