EcosystemRegistry

Struct EcosystemRegistry 

Source
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

Source

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);
Source

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)));
Source

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 ecosystem
  • None - 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());
}
Source

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 filename
  • None - 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());
}
Source

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 file
  • None - 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());
}
Source

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);
}
Source

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 file
  • None - 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());
}
Source

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

Source§

fn default() -> EcosystemRegistry

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more