Skip to main content

LockfileLoad

Enum LockfileLoad 

Source
pub enum LockfileLoad {
    Absent,
    Loaded {
        versions: HashMap<PackageName, ConcreteVersion>,
        candidates: HashMap<PackageName, Vec<ConcreteVersion>>,
    },
    Failed,
}
Expand description

Outcome of loading (or reloading) a lock file’s resolved-version data.

Replaces the earlier (HashMap, HashMap, bool) return shape (issue #1424): the trailing bool distinguished “reload OK: parsed, or genuinely absent” from “parse failed, or discovery panicked” only via a doc-comment convention, which two of three call sites simply ignored. As a named, exhaustive enum, that distinction is now a first-class value with its own documented Self::reload_ok method, not a bare bool a caller receives with no attached meaning. Self::into_maps is a deliberate escape hatch for a caller that only wants the maps: it collapses Self::Absent/Self::Failed alike, so nothing stops a caller from reaching for it without ever consulting Self::reload_ok first, exactly as a caller of the old tuple could ignore its bool. The improvement here is discoverability — the distinction has a name and a doc comment sitting right next to into_maps — not a compiler-enforced guarantee that every caller gets it right.

§Examples

use deps_core::{ConcreteVersion, PackageName};
use deps_engine::classify::resolved::LockfileLoad;
use std::collections::HashMap;

let load = LockfileLoad::Loaded {
    versions: HashMap::from([(PackageName::new("serde"), ConcreteVersion::from("1.0.210"))]),
    candidates: HashMap::new(),
};
assert!(load.reload_ok());
let (versions, _candidates) = load.into_maps();
assert_eq!(versions.len(), 1);

assert!(!LockfileLoad::Failed.reload_ok());
assert!(LockfileLoad::Absent.reload_ok());

Variants§

§

Absent

No LockFileProvider for this ecosystem, or no lock file found on disk — a genuine, non-error absence.

§

Loaded

A lock file was found and parsed successfully, possibly to zero packages.

Fields

§versions: HashMap<PackageName, ConcreteVersion>

dep_name -> version, one entry per name (see split_resolved_packages).

§candidates: HashMap<PackageName, Vec<ConcreteVersion>>

dep_name -> [version, ...], only for names with more than one retained entry.

§

Failed

A lock file was found but failed to parse (e.g. caught mid-rewrite by the package manager), or its discovery task panicked. Conservative: a panic is not a definitive “no lock file” answer the way a located-but-absent path is, so it is classified the same as a parse failure rather than as Self::Absent.

Implementations§

Source§

impl LockfileLoad

Source

pub fn reload_ok(&self) -> bool

Whether an empty-vs-non-empty transition read from this outcome is trustworthy: a genuine absence (Self::Absent) or a successful parse (Self::Loaded) — never a transient Self::Failed.

Callers that treat such a transition as a real signal (a resolved-version move worth re-scanning/diffing against) must gate on this — otherwise a transient parse failure looks identical to every dependency genuinely losing its resolution, silently discarding known-good data and replacing correct OSV/license results with Skipped/stale ones (the #1395 M1 class this mirrors).

Source

pub fn into_maps( self, ) -> (HashMap<PackageName, ConcreteVersion>, HashMap<PackageName, Vec<ConcreteVersion>>)

Extracts the resolved-version maps, falling back to a pair of empty maps for Self::Absent/Self::Failed.

Trait Implementations§

Source§

impl Clone for LockfileLoad

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 LockfileLoad

Source§

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

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

impl Eq for LockfileLoad

Source§

impl PartialEq for LockfileLoad

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 LockfileLoad

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