1use std::path::PathBuf;
4
5#[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
57impl Channel {
58 pub fn without_commit(mut self) -> Self {
62 self.commit = None;
63 self
64 }
65}
66
67#[cfg(test)]
68mod tests {
69 use super::*;
70
71 #[test]
72 fn without_commit_clears_only_the_commit() {
73 let ch = Channel {
74 name: "pantherx".into(),
75 url: "https://codeberg.org/gofranz/panther.git".into(),
76 branch: Some("master".into()),
77 commit: Some("deadbeef".into()),
78 introduction_commit: Some("54b4".into()),
79 introduction_fingerprint: Some("A36A".into()),
80 };
81 let stripped = ch.clone().without_commit();
82 assert_eq!(stripped.commit, None);
83 assert_eq!(stripped.branch, ch.branch);
84 assert_eq!(stripped.introduction_commit, ch.introduction_commit);
85 assert_eq!(stripped.name, ch.name);
86 }
87}
88
89#[derive(Debug, Clone, Copy, PartialEq, Eq)]
90pub enum ProgressStream {
91 Stdout,
92 Stderr,
93}
94
95#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
96pub enum KnownBug {
97 ChannelShadow74396,
99}
100
101impl KnownBug {
102 pub fn url(self) -> &'static str {
103 match self {
104 KnownBug::ChannelShadow74396 => "https://issues.guix.gnu.org/74396",
105 }
106 }
107}
108
109#[derive(Debug, Clone, PartialEq)]
110pub enum ProgressEvent {
111 Line {
113 stream: ProgressStream,
114 text: String,
115 redraw: bool,
116 },
117
118 SubstituteLookup {
119 url: String,
120 percent: f32,
121 },
122
123 SubstituteDownload {
124 item: String,
125 bytes_done: u64,
126 bytes_total: Option<u64>,
127 },
128
129 SubstituteDownloadDone {
131 item: String,
132 bytes_total: Option<u64>,
133 },
134
135 BuildStart {
136 drv: String,
137 },
138
139 BuildPhase {
140 drv: Option<String>,
141 phase: String,
142 },
143
144 BuildDone {
145 drv: String,
146 },
147
148 BuildFailed {
149 drv: String,
150 log_path: Option<String>,
151 },
152
153 WouldDownload {
154 bytes: u64,
155 items: Vec<String>,
156 },
157
158 WouldBuild {
159 bytes: u64,
160 items: Vec<String>,
161 },
162
163 StorePathListed {
164 path: String,
165 },
166
167 PullComputingDerivation {
168 system: String,
169 },
170
171 DryRunHeader {
172 text: String,
173 },
174
175 KnownBug(KnownBug),
176
177 ExitSummary {
179 code: i32,
180 duration_secs: f64,
181 },
182}