1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//!
//! [nix-uri](https://crates.io/crates/nix-uri) is a rust crate that parses
//! the [nix-uri-scheme](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake#url-like-syntax)
//! into a [`flakeref::FlakeRef`] struct.
//!
//! Also allows for building a `nix-uri` through the [`flakeref::FlakeRef`]
//! struct.
//!
//! Convenience functionality for working with nix `flake.nix` references (flakerefs).
//! Provides types for the generic attribute set representation, but does not parse it:
//!
//! ``` markdown
//! {
//! type = "github";
//! owner = "NixOS";
//! repo = "nixpkgs";
//! }
//! ```
//!
//! ## Installation
//!
//! To use `nix-uri`, add it as a dependency in your `Cargo.toml` file:
//!
//! ```markdown
//! [dependencies]
//! nix-uri = "0.2.0"
//! ```
//!
//! or use `cargo add`:
//!
//! ```markdown
//! cargo add nix-uri
//! ```
//!
//! # Examples
//! Check out the examples directory, for more information, or run an example:
//!
//! ```markdown
//! cargo run --example simple
//! cargo run --example cli github:nixos/nixpkgs
//! ```
//!
//! The uri syntax representation is parsed by this library:
//! ## Example: Parsing from `github:nixos/nixpkgs`:
//!
//! ```
//! # use nix_uri::{FlakeRef, FlakeRefType, GitForgePlatform};
//! let uri = "github:nixos/nixpkgs";
//! let parsed: FlakeRef = uri.parse().unwrap();
//! match parsed.kind() {
//! FlakeRefType::GitForge(forge) => {
//! assert_eq!(forge.platform, GitForgePlatform::GitHub);
//! assert_eq!(forge.owner, "nixos");
//! assert_eq!(forge.repo, "nixpkgs");
//! assert!(forge.ref_.is_none() && forge.rev.is_none());
//! }
//! _ => panic!("expected GitForge"),
//! }
//! ```
//!
//! The `Display` round-trip preserves the original form:
//! ## Example: Round-tripping `github:nixos/nixpkgs`:
//! ```
//! # use nix_uri::FlakeRef;
//! let uri = "github:nixos/nixpkgs";
//! let parsed: FlakeRef = uri.parse().unwrap();
//! assert_eq!(uri, parsed.to_string());
//! ```
pub
pub use ;
pub use ;