Skip to main content

LockFile

Struct LockFile 

Source
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>

Source

pub fn parse(bytes: &'a [u8]) -> Result<Self, Error>

Parse a version 5, 6, or 7 lock file using default resource limits.

Source

pub fn parse_with_limits(bytes: &'a [u8], limits: Limits) -> Result<Self, Error>

Parse a lock file using caller-supplied resource limits.

Source

pub const fn source_version(&self) -> u8

Return the version found in the source document.

Canonical serialization always writes version 7.

Source

pub const fn root_id(&self) -> NodeId

Return the root node identifier.

Source

pub fn root(&self) -> &Node<'a>

Return the root node.

Source

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.

Source

pub fn nodes(&self) -> impl ExactSizeIterator<Item = (NodeId, &Node<'a>)>

Iterate over all reachable nodes in arena order.

Source

pub fn node_count(&self) -> usize

Return the number of reachable nodes, including the root.

Source

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.

Source

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.

Source

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.

Source

pub fn changes<'b>(&self, newer: &LockFile<'b>) -> Vec<Change>

Return semantic input changes between this lock file and newer.

Source

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.

Source

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.

Source

pub fn to_nix_bytes(&self) -> Vec<u8> ⓘ

Serialize to newly allocated Nix-compatible version 7 JSON bytes.

Source

pub fn into_owned(self) -> LockFile<'static>

Convert all borrowed strings into owned strings.

Trait Implementations§

Source§

impl<'a> Clone for LockFile<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for LockFile<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for LockFile<'_>

Source§

impl<'a, 'b> PartialEq<LockFile<'b>> for LockFile<'a>

Source§

fn eq(&self, other: &LockFile<'b>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for LockFile<'a>

§

impl<'a> RefUnwindSafe for LockFile<'a>

§

impl<'a> Send for LockFile<'a>

§

impl<'a> Sync for LockFile<'a>

§

impl<'a> Unpin for LockFile<'a>

§

impl<'a> UnsafeUnpin for LockFile<'a>

§

impl<'a> UnwindSafe for LockFile<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.