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
impl LockfileLoad
Sourcepub fn reload_ok(&self) -> bool
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).
Sourcepub fn into_maps(
self,
) -> (HashMap<PackageName, ConcreteVersion>, HashMap<PackageName, Vec<ConcreteVersion>>)
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
impl Clone for LockfileLoad
Source§impl Debug for LockfileLoad
impl Debug for LockfileLoad
impl Eq for LockfileLoad
Source§impl PartialEq for LockfileLoad
impl PartialEq for LockfileLoad
impl StructuralPartialEq for LockfileLoad
Auto Trait Implementations§
impl Freeze for LockfileLoad
impl RefUnwindSafe for LockfileLoad
impl Send for LockfileLoad
impl Sync for LockfileLoad
impl Unpin for LockfileLoad
impl UnsafeUnpin for LockfileLoad
impl UnwindSafe for LockfileLoad
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.