pub struct Lockfile {
pub version: u32,
pub pkg: Vec<LockedPkg>,
}Expand description
Root structure of mlua-pkg.lock.
Use Lockfile::read to load an existing lockfile and Lockfile::write
to persist one. Lockfile::default creates an empty lockfile with
version = 1.
Unknown top-level keys cause an immediate parse error
(#[serde(deny_unknown_fields)]).
Fields§
§version: u32Schema version. Always 1 in this implementation.
Future tooling may bump this number and apply a migration before deserializing the rest of the file.
pkg: Vec<LockedPkg>Locked package entries. Written as [[pkg]] in TOML.
May be empty for a newly-initialized lockfile (no deps installed yet).
Implementations§
Source§impl Lockfile
impl Lockfile
Sourcepub fn read(path: impl AsRef<Path>) -> Result<Self, PkgError>
pub fn read(path: impl AsRef<Path>) -> Result<Self, PkgError>
Read and parse a mlua-pkg.lock file at path.
§Errors
| Error | Condition |
|---|---|
PkgError::MissingLockfile | File does not exist |
PkgError::LockfileParse | Invalid TOML or unknown / missing fields |
PkgError::SameNameConflict | Duplicate name in [[pkg]] entries |
PkgError::Io | Other I/O failure |
Sourcepub fn write(&self, path: impl AsRef<Path>) -> Result<(), PkgError>
pub fn write(&self, path: impl AsRef<Path>) -> Result<(), PkgError>
Write the lockfile to path.
Packages are sorted by name before writing to produce diff-stable output suitable for version control.
This implementation uses fs::write (not atomic). Atomic write
via tempfile::NamedTempFile::persist is a planned enhancement for
a future subtask.
§Errors
| Error | Condition |
|---|---|
PkgError::LockfileWrite | TOML serialization failed |
PkgError::Io | File write failed |
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Lockfile
impl<'de> Deserialize<'de> for Lockfile
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Lockfile
impl StructuralPartialEq 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 UnsafeUnpin 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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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<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