pub struct FlakeLock {
pub nodes: BTreeMap<String, FlakeNode>,
pub root: String,
pub version: u32,
}Expand description
A parsed and validated flake.lock file.
Fields§
§nodes: BTreeMap<String, FlakeNode>All nodes keyed by their name.
root: StringName of the root node (usually "root").
version: u32Lock file schema version (must be 7).
Implementations§
Source§impl FlakeLock
impl FlakeLock
Sourcepub fn parse(json: &str) -> Result<Self, FlakeLockError>
pub fn parse(json: &str) -> Result<Self, FlakeLockError>
Parse a flake.lock from its JSON text.
Sourcepub fn to_json(&self) -> Result<String, FlakeLockError>
pub fn to_json(&self) -> Result<String, FlakeLockError>
Serialize the lock back to pretty-printed JSON.
Sourcepub fn root_node(&self) -> Result<&FlakeNode, FlakeLockError>
pub fn root_node(&self) -> Result<&FlakeNode, FlakeLockError>
Get the root node.
Sourcepub fn root_inputs(&self) -> Result<Vec<(String, String)>, FlakeLockError>
pub fn root_inputs(&self) -> Result<Vec<(String, String)>, FlakeLockError>
Return the direct inputs of the root node as (input_name, node_name) pairs,
resolving follows along the way.
Sourcepub fn resolve_ref(
&self,
_parent: &str,
input_ref: &InputRef,
) -> Result<String, FlakeLockError>
pub fn resolve_ref( &self, _parent: &str, input_ref: &InputRef, ) -> Result<String, FlakeLockError>
Resolve an InputRef to a concrete node name.
Direct(name)simply returnsname.Follows(path)walks the path from the root node (Nix semantics:["nixpkgs"]means “follow root’s nixpkgs input”;["utils", "nixpkgs"]means “follow root -> utils -> nixpkgs”).
Sourcepub fn resolve_input(&self, path: &[&str]) -> Result<&FlakeNode, FlakeLockError>
pub fn resolve_input(&self, path: &[&str]) -> Result<&FlakeNode, FlakeLockError>
Walk the input graph from the root following a dotted-style path.
resolve_input(&["utils", "nixpkgs"]) starts at root, enters the
utils input, then enters that node’s nixpkgs input, resolving any
follows along the way.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FlakeLock
impl<'de> Deserialize<'de> for FlakeLock
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for FlakeLock
impl RefUnwindSafe for FlakeLock
impl Send for FlakeLock
impl Sync for FlakeLock
impl Unpin for FlakeLock
impl UnsafeUnpin for FlakeLock
impl UnwindSafe for FlakeLock
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
Mutably borrows from an owned value. Read more