pub async fn parse_known_lockfile(
lockfile_cache: &LockFileCache,
lock_provider: &dyn LockFileProvider,
lockfile_path: &Path,
) -> LockfileLoadExpand description
Parses the lock file at lockfile_path through lockfile_cache, converting the result
into a LockfileLoad::Loaded or LockfileLoad::Failed outcome.
lockfile_path is a path already known to exist — resolved by
load_resolved_versions’s own discovery step, or by a caller reacting to a
file-watcher event for a path it already knows. Never returns LockfileLoad::Absent —
only load_resolved_versions’s discovery step (no lock file located at all) can
conclude that; a known path means discovery already succeeded.
Shared by load_resolved_versions and deps-lsp’s watched-lock-file-change handler
(issue #1424) — both need the identical get-or-parse-then-split sequence, previously
duplicated between them.
§Examples
use deps_core::{Ecosystem, HttpCache};
use deps_core::lockfile::LockFileCache;
use deps_engine::classify::resolved::{LockfileLoad, parse_known_lockfile};
use deps_engine::setup::CargoEcosystem;
use std::path::Path;
use std::sync::Arc;
#[tokio::main]
async fn main() {
let ecosystem = CargoEcosystem::new(Arc::new(HttpCache::new()));
let lockfile_cache = LockFileCache::new();
let lock_provider = ecosystem.lockfile_provider().unwrap();
// The path itself doesn't exist, so parsing fails.
let load = parse_known_lockfile(
&lockfile_cache,
lock_provider.as_ref(),
Path::new("/nonexistent-for-doctest/Cargo.lock"),
)
.await;
assert_eq!(load, LockfileLoad::Failed);
}