pub struct LockFile {
pub version: u64,
pub packages: BTreeSet<LockedPackage>,
/* private fields */
}
Expand description
Represents a resolved dependency lock file.
This is a TOML file that contains the resolved dependency information from a previous build.
Fields§
§version: u64
The version of the lock file.
Currently this is always 1
.
packages: BTreeSet<LockedPackage>
The locked dependencies in the lock file.
This list is sorted by the name of the locked package.
Implementations§
Source§impl LockFile
impl LockFile
Sourcepub async fn new_with_path(
packages: impl IntoIterator<Item = LockedPackage>,
path: impl AsRef<Path>,
) -> Result<Self>
pub async fn new_with_path( packages: impl IntoIterator<Item = LockedPackage>, path: impl AsRef<Path>, ) -> Result<Self>
Creates a new lock file from the given packages at the given path. This will create an empty
file and get an exclusive lock on the file, but will not write the data to the file unless
write
is called.
Sourcepub async fn load_from_path(
path: impl AsRef<Path>,
readonly: bool,
) -> Result<Self>
pub async fn load_from_path( path: impl AsRef<Path>, readonly: bool, ) -> Result<Self>
Loads a lock file from the given path. If readonly is set to false, then an exclusive lock will be acquired on the file. This function will block until the lock is acquired.
Sourcepub async fn from_dependencies(
map: &DependencyResolutionMap,
path: impl AsRef<Path>,
) -> Result<LockFile>
pub async fn from_dependencies( map: &DependencyResolutionMap, path: impl AsRef<Path>, ) -> Result<LockFile>
Creates a lock file from the dependency map. This will create an empty file (if it doesn’t
exist) and get an exclusive lock on the file, but will not write the data to the file unless
write
is called.
Sourcepub fn update_dependencies(&mut self, map: &DependencyResolutionMap)
pub fn update_dependencies(&mut self, map: &DependencyResolutionMap)
A helper for updating the current lock file with the given dependency map. This will clear current packages that are not in the dependency map and add new packages that are in the dependency map.
This function will not write the data to the file unless write
is called.
Sourcepub async fn load(readonly: bool) -> Result<Self>
pub async fn load(readonly: bool) -> Result<Self>
Attempts to load the lock file from the current directory. Most of the time, users of this
crate should use this function. Right now it just checks for a wkg.lock
file in the
current directory, but we could add more resolution logic in the future. If the file is not
found, a new file is created and a default empty lockfile is returned. This function will
block until the lock is acquired.
Sourcepub fn resolve(
&self,
registry: Option<&str>,
package_ref: &PackageRef,
requirement: &VersionReq,
) -> Result<Option<&LockedPackageVersion>>
pub fn resolve( &self, registry: Option<&str>, package_ref: &PackageRef, requirement: &VersionReq, ) -> Result<Option<&LockedPackageVersion>>
Resolves a package from the lock file.
Returns Ok(None)
if the package cannot be resolved.
Fails if the package cannot be resolved and the lock file is not allowed to be updated.
Trait Implementations§
impl Eq for LockFile
Auto Trait Implementations§
impl !Freeze for LockFile
impl !RefUnwindSafe for LockFile
impl Send for LockFile
impl Sync for LockFile
impl Unpin for LockFile
impl !UnwindSafe for LockFile
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<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.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more