Skip to main content

libguix/
types.rs

1//! Public data types.
2
3use std::path::PathBuf;
4
5/// Empty strings rather than `Option` — these are display fields.
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct PackageSummary {
8    pub name: String,
9    pub version: String,
10    pub synopsis: String,
11    pub description: String,
12    pub homepage: String,
13    pub license: String,
14    pub outputs: Vec<String>,
15}
16
17#[derive(Debug, Clone, PartialEq, Eq)]
18pub struct PackageDetail {
19    pub name: String,
20    pub version: String,
21    pub synopsis: String,
22    pub description: String,
23    pub homepage: Option<String>,
24    pub license: Option<String>,
25    pub location: Option<String>,
26    pub outputs: Vec<String>,
27    pub systems: Vec<String>,
28    pub dependencies: Vec<String>,
29}
30
31#[derive(Debug, Clone, PartialEq, Eq)]
32pub struct InstalledPackage {
33    pub name: String,
34    pub version: String,
35    pub output: String,
36    pub store_path: PathBuf,
37}
38
39#[derive(Debug, Clone, PartialEq, Eq)]
40pub struct Generation {
41    pub number: u32,
42    pub date: String,
43    pub current: bool,
44    pub packages: Vec<InstalledPackage>,
45}
46
47#[derive(Debug, Clone, PartialEq, Eq)]
48pub struct Channel {
49    pub name: String,
50    pub url: String,
51    pub branch: Option<String>,
52    pub commit: Option<String>,
53    pub introduction_commit: Option<String>,
54    pub introduction_fingerprint: Option<String>,
55}
56
57#[derive(Debug, Clone, Copy, PartialEq, Eq)]
58pub enum ProgressStream {
59    Stdout,
60    Stderr,
61}
62
63#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
64pub enum KnownBug {
65    /// <https://issues.guix.gnu.org/74396>.
66    ChannelShadow74396,
67}
68
69impl KnownBug {
70    pub fn url(self) -> &'static str {
71        match self {
72            KnownBug::ChannelShadow74396 => "https://issues.guix.gnu.org/74396",
73        }
74    }
75}
76
77#[derive(Debug, Clone, PartialEq)]
78pub enum ProgressEvent {
79    /// `redraw: true` ↔ `\r`-terminated upstream — replace, don't append.
80    Line {
81        stream: ProgressStream,
82        text: String,
83        redraw: bool,
84    },
85
86    SubstituteLookup {
87        url: String,
88        percent: f32,
89    },
90
91    SubstituteDownload {
92        item: String,
93        bytes_done: u64,
94        bytes_total: Option<u64>,
95    },
96
97    /// Only emitted from the REPL fd-3 stream — the stderr path has no equivalent.
98    SubstituteDownloadDone {
99        item: String,
100        bytes_total: Option<u64>,
101    },
102
103    BuildStart {
104        drv: String,
105    },
106
107    BuildPhase {
108        drv: Option<String>,
109        phase: String,
110    },
111
112    BuildDone {
113        drv: String,
114    },
115
116    BuildFailed {
117        drv: String,
118        log_path: Option<String>,
119    },
120
121    WouldDownload {
122        bytes: u64,
123        items: Vec<String>,
124    },
125
126    WouldBuild {
127        bytes: u64,
128        items: Vec<String>,
129    },
130
131    StorePathListed {
132        path: String,
133    },
134
135    PullComputingDerivation {
136        system: String,
137    },
138
139    DryRunHeader {
140        text: String,
141    },
142
143    KnownBug(KnownBug),
144
145    /// Synthesised at end-of-stream. Always the final event.
146    ExitSummary {
147        code: i32,
148        duration_secs: f64,
149    },
150}