Skip to main content

DependencySource

Enum DependencySource 

Source
#[non_exhaustive]
pub enum DependencySource { Registry, Git { url: String, rev: Option<String>, }, Path { path: String, }, Url { url: String, }, Sdk { sdk: String, }, Workspace, CustomRegistry { url: String, }, AlternateRegistry { index: String, mirrors_crates_io: bool, }, }
Expand description

Dependency source location (shared across all ecosystems).

Covers the union of all source types across Cargo, npm, PyPI, Go, Dart, Bundler, Maven, and Gradle ecosystems.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Registry

Default package registry (crates.io, npm, PyPI, pub.dev, rubygems.org, Maven Central).

§

Git

Git repository dependency.

Fields

§url: String

Repository URL.

§rev: Option<String>

Git ref: commit SHA, tag, or branch name (ecosystem-specific semantics).

§

Path

Local filesystem path dependency.

Fields

§path: String

Filesystem path, relative or absolute, as written in the manifest.

§

Url

Direct URL to artifact (PyPI wheels, npm tarballs).

Fields

§url: String

URL the artifact is fetched from.

§

Sdk

SDK-provided dependency (Dart: sdk: flutter).

Fields

§sdk: String

Name of the SDK providing this dependency.

§

Workspace

Workspace-inherited dependency (Cargo: workspace = true).

§

CustomRegistry

Custom/alternative registry, named by an unresolved alias or raw index URL (Bundler custom sources, an unresolved Cargo registry = "my-corp").

This variant’s meaning is unchanged by AlternateRegistry’s addition: it always means “not yet resolved to a concrete index this LSP can query” — url may hold a bare alias ("my-corp") or a URL string, but never a value this LSP has validated and can fetch against. See AlternateRegistry for the resolved counterpart.

url itself is stored raw (unresolved alias or a literal registry-index, possibly carrying user:pass@ userinfo or a credential-bearing query string) — never redact this field in place, since dedup_dependencies_by_source’s collision check and other equality-based logic must keep comparing the real value. DependencySource’s own Debug impl redacts it via RedactedUrl before it can reach a log line; any future caller rendering url into hover/diagnostics text (currently latent — nothing does today) must redact it the same way rather than relying on Debug alone.

Fields

§url: String

Unresolved alias or raw index URL — redacted only when Debug-formatted (see the variant’s own doc).

§

AlternateRegistry

A custom/alternative registry resolved to a concrete, fetchable index URL.

Distinct from CustomRegistry so “resolved” is a type-level state instead of string-sniffing an unresolved alias vs. a URL. Produced only by a parser that validated index against its own registry-configuration source (e.g. deps-cargo’s .cargo/config.toml resolution) — deps-core itself never constructs this variant. index is the sparse+ prefix-stripped, https-only index URL — userinfo is rejected by validate_index_url before a URL can resolve to this variant, but a credential-bearing query string is not stripped there and CAN still be present (#935); DependencySource’s own Debug impl redacts index via RedactedUrl so a tracing::warn!(?source, ...) call site can never leak one. index is not itself an authorization decision — see the originating crate’s config-resolution module for how (and whether) a request against it is authenticated.

Fields

§index: String

The resolved index URL, validated and normalized by the originating parser — redacted only when Debug-formatted (see the variant’s own doc).

§mirrors_crates_io: bool

true exactly when this source was reached via a [source.crates-io] replace-with chain (Cargo [source] mirroring, spec .local/specs/023-cargo-custom-registries/plan-1b.md §1.3) — as opposed to an explicit registry/registry-index naming a genuinely different, private registry.

Affects presentation and advisory gating only, never routing: Cargo verifies per-version checksum equality against crates.io for a mirror, so its content is exactly as trustworthy as crates.io’s own for vulnerability-scanning and hover-link purposes, even though the fetch itself still goes to index, not to crates.io. See crate::lsp_helpers::SourcePolicy::source_is_public_registry_content.

Implementations§

Source§

impl DependencySource

Source

pub fn is_registry(&self) -> bool

Returns true if this dependency comes from any registry (default or custom).

Registry dependencies support version fetching and update checks. Git, Path, Url, Sdk, and Workspace dependencies do not.

Source

pub fn is_version_resolvable(&self) -> bool

Returns true if this LSP can resolve version data for this source against the registry client it actually queries.

Registry resolves to the ecosystem’s default public registry (crates.io, npm, PyPI, …), which every deps-* crate implements a client for. CustomRegistry names a private/alternative registry (e.g. Bundler source "https://gems.mycorp.com", Cargo registry = "my-corp") that this LSP has no client for — known limitation, tracked until private-registry client support exists. Diagnostics and hover must not silently fall back to checking a CustomRegistry dependency’s name against the public registry, so this deliberately diverges from is_registry() and returns false for it, alongside Git/Path/Url/Sdk/Workspace sources.

Also false for AlternateRegistry, even though it is resolved: this method answers “does the generic Registry trait (crates.io-shaped, one client per ecosystem) resolve this”, not “is version data reachable at all”. An ecosystem whose registry implements per-source routing (deps-cargo’s CargoRegistry) must use crate::lsp_helpers::SourcePolicy::can_resolve_source instead, which defaults to this method and is the only override point — see that method’s docs.

Trait Implementations§

Source§

impl Clone for DependencySource

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DependencySource

Hand-written, not derived (#935): a derived Debug would have printed Git.url, Url.url, CustomRegistry.url, and AlternateRegistry.index raw — every one of them can carry a credential (userinfo or a query-string secret) that never gets a chance to be stripped, since none of these fields is validated/redacted before construction on every code path (see DependencySource::AlternateRegistry and DependencySource::CustomRegistry’s own docs). Any tracing::warn!(?source, ...) or {source:?} call site — a common, idiomatic alternative to a hand-rolled Display — must not be able to reopen this leak, so it is closed once here at the type level instead of at each logging call site. Every variant and field is still shown (this is not a summary); only URL-bearing field values are routed through RedactedUrl first.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for DependencySource

Source§

impl PartialEq for DependencySource

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DependencySource

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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