pub struct LockFile<'a> { /* private fields */ }Expand description
A parsed Nix flake lock file.
Unescaped strings borrow from the input. Call LockFile::into_owned when
the value must outlive the input buffer. The graph is intentionally
read-only; serialization always emits Nix’s canonical version 7 form.
Implementations§
Source§impl<'a> LockFile<'a>
impl<'a> LockFile<'a>
Sourcepub fn parse(bytes: &'a [u8]) -> Result<Self, Error>
pub fn parse(bytes: &'a [u8]) -> Result<Self, Error>
Parse a version 5, 6, or 7 lock file using default resource limits.
Sourcepub fn parse_with_limits(bytes: &'a [u8], limits: Limits) -> Result<Self, Error>
pub fn parse_with_limits(bytes: &'a [u8], limits: Limits) -> Result<Self, Error>
Parse a lock file using caller-supplied resource limits.
Sourcepub const fn source_version(&self) -> u8
pub const fn source_version(&self) -> u8
Return the version found in the source document.
Canonical serialization always writes version 7.
Sourcepub fn node(&self, id: NodeId) -> Option<&Node<'a>>
pub fn node(&self, id: NodeId) -> Option<&Node<'a>>
Look up a node by identifier.
A NodeId is meaningful only for the LockFile that produced it.
Sourcepub fn nodes(&self) -> impl ExactSizeIterator<Item = (NodeId, &Node<'a>)>
pub fn nodes(&self) -> impl ExactSizeIterator<Item = (NodeId, &Node<'a>)>
Iterate over all reachable nodes in arena order.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Return the number of reachable nodes, including the root.
Sourcepub fn resolve<'p, I>(&'p self, path: I) -> Result<Option<NodeId>, ResolveError>where
I: IntoIterator<Item = &'p str>,
pub fn resolve<'p, I>(&'p self, path: I) -> Result<Option<NodeId>, ResolveError>where
I: IntoIterator<Item = &'p str>,
Resolve an input path from the root node.
Returns Ok(None) when a component does not exist.
Sourcepub fn resolve_path(
&self,
path: &InputPath<'_>,
) -> Result<Option<NodeId>, ResolveError>
pub fn resolve_path( &self, path: &InputPath<'_>, ) -> Result<Option<NodeId>, ResolveError>
Resolve a parsed input path from the root node.
This avoids the temporary path collection required by Self::resolve.
Sourcepub fn validate(&self) -> Result<(), ValidationError>
pub fn validate(&self) -> Result<(), ValidationError>
Validate all follows edges in the reachable graph.
This checks for missing targets and follows cycles. It does not fetch
inputs or apply fetcher-specific validity rules.
Sourcepub fn changes<'b>(&self, newer: &LockFile<'b>) -> Vec<Change>
pub fn changes<'b>(&self, newer: &LockFile<'b>) -> Vec<Change>
Return semantic input changes between this lock file and newer.
Sourcepub fn semantically_eq(&self, other: &LockFile<'_>) -> bool
pub fn semantically_eq(&self, other: &LockFile<'_>) -> bool
Return whether two rooted graphs have the same semantic lock content.
Source versions, source node keys, arena order, and string ownership do not affect semantic equality. Node sharing and cycles are preserved.
Sourcepub fn write_nix(&self, output: &mut Vec<u8>)
pub fn write_nix(&self, output: &mut Vec<u8>)
Append Nix-compatible, two-space-indented version 7 JSON to output.
The emitted document includes the trailing newline used for flake.lock.
Sourcepub fn to_nix_bytes(&self) -> Vec<u8> ⓘ
pub fn to_nix_bytes(&self) -> Vec<u8> ⓘ
Serialize to newly allocated Nix-compatible version 7 JSON bytes.
Sourcepub fn into_owned(self) -> LockFile<'static>
pub fn into_owned(self) -> LockFile<'static>
Convert all borrowed strings into owned strings.