pub trait LockFileProvider: Send + Sync {
// Required methods
fn locate_lockfile(&self, manifest_uri: &Uri) -> Option<PathBuf>;
fn parse_lockfile<'life0, 'life1, 'async_trait>(
&'life0 self,
lockfile_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<ResolvedPackages>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn is_lockfile_stale(
&self,
lockfile_path: &Path,
last_modified: SystemTime,
) -> bool { ... }
}Expand description
Lock file provider trait for ecosystem-specific implementations.
Implementations parse lock files for a specific package ecosystem (Cargo.lock, package-lock.json, etc.) and extract resolved versions.
§Examples
use deps_core::lockfile::{LockFileProvider, ResolvedPackages};
use async_trait::async_trait;
use std::path::{Path, PathBuf};
use tower_lsp_server::ls_types::Uri;
struct MyLockParser;
#[async_trait]
impl LockFileProvider for MyLockParser {
fn locate_lockfile(&self, manifest_uri: &Uri) -> Option<PathBuf> {
let manifest_path = manifest_uri.to_file_path()?;
let lock_path = manifest_path.with_file_name("my.lock");
lock_path.exists().then_some(lock_path)
}
async fn parse_lockfile(&self, lockfile_path: &Path) -> deps_core::error::Result<ResolvedPackages> {
// Parse lock file format and extract packages
Ok(ResolvedPackages::new())
}
}Required Methods§
Sourcefn locate_lockfile(&self, manifest_uri: &Uri) -> Option<PathBuf>
fn locate_lockfile(&self, manifest_uri: &Uri) -> Option<PathBuf>
Sourcefn parse_lockfile<'life0, 'life1, 'async_trait>(
&'life0 self,
lockfile_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<ResolvedPackages>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn parse_lockfile<'life0, 'life1, 'async_trait>(
&'life0 self,
lockfile_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<ResolvedPackages>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Provided Methods§
Sourcefn is_lockfile_stale(
&self,
lockfile_path: &Path,
last_modified: SystemTime,
) -> bool
fn is_lockfile_stale( &self, lockfile_path: &Path, last_modified: SystemTime, ) -> bool
Checks if lock file has been modified since last parse.
Used for cache invalidation. Default implementation compares file modification time.
§Arguments
lockfile_path- Path to the lock filelast_modified- Last known modification time
§Returns
true if file has been modified or cannot be stat’d, false otherwise