Skip to main content

PackageVersions

Struct PackageVersions 

Source
pub struct PackageVersions {
    pub latest: ConcreteVersion,
    pub available: Arc<[ConcreteVersion]>,
    pub yanked: Arc<[(ConcreteVersion, RemovalStatus)]>,
    pub published_at: Option<PublishTime>,
}
Expand description

Registry version data for one package, fetched together in a single round trip.

latest and available are deliberately asymmetric — this is load-bearing, not an oversight:

  • latest comes from this ecosystem’s own Registry::select_latest_matching(.., "*") pick, which excludes yanked (and, for semver/node-semver *, prerelease) versions — the same value get_latest_matching returned before this type existed.
  • available is the unfiltered get_versions output: every published version, newest-first, yanked and prerelease entries included.

The unsatisfiable-requirement check (see crate::lsp_helpers::requirement_is_unsatisfiable) scans available and deliberately does not filter it: a requirement that only matches a yanked or prerelease version is still satisfied, so filtering available the same way latest is filtered would produce false “no published version satisfies” warnings.

yanked is the subset of available (same version-string encoding) that the registry reported as yanked/deprecated, paired with each entry’s RemovalStatus. It exists because Registry::get_latest_matching — the call that used to populate this cache — filters yanked entries out by contract on every current registry implementation, so a per-version yanked flag threaded through that call would always read false (see #233). available now comes from the unfiltered get_versions instead, which does observe yanked entries, so yanked is derived from that same fetch rather than discarded.

The status rides alongside each version (rather than a bare membership list) so crate::lsp_helpers::generate_diagnostics_from_cache’s #247 “requirement satisfiable only by a yanked version” check can gate its own package-level-deprecation suppression on AdvisoryDeprecated specifically, never on a genuine Yanked finding — mirroring VersionData::outcomes’s D5 gate for the #263 in-use-version check (see #437).

Fields§

§latest: ConcreteVersion

Latest usable version for this package.

§available: Arc<[ConcreteVersion]>

Every published version, newest-first, unfiltered.

§yanked: Arc<[(ConcreteVersion, RemovalStatus)]>

Subset of available reported as yanked/deprecated by the registry, each paired with its RemovalStatus.

§published_at: Option<PublishTime>

When latest was published, if the registry exposes it. None when the ecosystem doesn’t wire crate::Version::published_at or the fetch never ran.

Deliberately a field on this single per-package struct rather than a second parallel map keyed alongside latest — the earlier two-map design (issue #227 critique C3) let latest and its age drift apart silently whenever one map was updated (e.g. lockfile-resolved overwrite) without the other. Bundling them here makes that desync impossible: whoever sets latest sets published_at too.

Implementations§

Source§

impl PackageVersions

Source

pub fn latest_only(latest: impl Into<ConcreteVersion>) -> Self

Builds a PackageVersions from only the “latest” version string, with available populated as the single-element list [latest].

Test-only in intent. The one-element available this produces is a real, if small, version list — it is not “empty/unknown”, so requirement_is_unsatisfiable will evaluate a requirement against it. Do not use this for a lock-file-only population path that has no real version list to offer (use latest_without_list there instead, which leaves available genuinely empty) — that exact substitution is the false-positive N5 was written to prevent: it would let the unsatisfiable-requirement check produce a verdict against a fabricated one-entry list before any registry fetch has run. Real registry fetches always populate available from the full get_versions result instead of using either constructor.

§Examples
use deps_core::{ConcreteVersion, PackageVersions};

let versions = PackageVersions::latest_only("1.0.214");
assert_eq!(versions.latest, "1.0.214");
assert_eq!(&*versions.available, &[ConcreteVersion::new("1.0.214")]);
Source

pub fn latest_without_list(latest: impl Into<ConcreteVersion>) -> Self

Builds a PackageVersions with no version list — used where only the “latest” value is known and probing further would be misleading, notably the lock-file population path (crates/deps-lsp/src/document/lifecycle.rs), which must not populate a plausible-looking one-element available list before any registry fetch has run: the unsatisfiable-requirement check treats an empty available as “still loading, skip”.

§Examples
use deps_core::PackageVersions;

let versions = PackageVersions::latest_without_list("1.0.195");
assert_eq!(versions.latest, "1.0.195");
assert!(versions.available.is_empty());

Trait Implementations§

Source§

impl Clone for PackageVersions

Source§

fn clone(&self) -> PackageVersions

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 PackageVersions

Source§

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

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

impl Eq for PackageVersions

Source§

impl PartialEq for PackageVersions

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for PackageVersions

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
§

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

§

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

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

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

§

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

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

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

§

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.

§

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.

§

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

§

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
§

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 = 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