pub fn locate_lockfile_for_manifest(
manifest_uri: &Uri,
lockfile_names: &[&str],
) -> Option<PathBuf>Expand description
Generic lock file locator.
Searches for lock files in the following order:
- Same directory as the manifest
- Parent directories (up to MAX_WORKSPACE_DEPTH levels) for workspace root
This function is ecosystem-agnostic and works with any lock file name.
§Arguments
manifest_uri- URI of the manifest filelockfile_names- List of possible lock file names to search for
§Returns
Path to the first found lock file, or None if not found.
§Examples
use deps_core::lockfile::locate_lockfile_for_manifest;
use tower_lsp_server::ls_types::Uri;
let manifest_uri = Uri::from_file_path("/path/to/Cargo.toml").unwrap();
let lockfile_names = &["Cargo.lock"];
if let Some(path) = locate_lockfile_for_manifest(&manifest_uri, lockfile_names) {
println!("Found lock file at: {}", path.display());
}