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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
use serde_derive::Deserialize;
use std::io::Read;
pub struct TmplBuilder {
pub pkg_name: String,
pub pkg_type: Option<PkgType>,
pub pkg_info: Option<PkgInfo>,
}
pub struct Template {
pub inner: String,
pub name: String,
}
impl Read for Template {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
self.inner.as_bytes().read(buf)
}
}
#[derive(Copy, Clone, Eq, Ord, PartialOrd, Hash, Debug, PartialEq)]
pub enum PkgType {
Crate,
Gem,
PerlDist,
}
#[derive(Clone, Eq, Ord, PartialOrd, Hash, Default, Debug, PartialEq)]
pub struct Dependencies {
pub host: Option<Vec<String>>,
pub make: Option<Vec<String>>,
pub run: Option<Vec<String>>,
}
#[derive(Clone, Eq, Ord, PartialOrd, Hash, Default, Debug, PartialEq)]
pub struct PkgInfo {
pub pkg_name: String,
pub version: String,
pub description: Option<String>,
pub homepage: String,
pub license: Option<Vec<String>>,
pub dependencies: Option<Dependencies>,
pub sha: String,
pub download_url: Option<String>,
}
pub(super) struct DownloadProgress<R> {
pub inner: R,
pub progress_bar: indicatif::ProgressBar,
}
impl<R: std::io::Read> std::io::Read for DownloadProgress<R> {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
self.inner.read(buf).map(|n| {
self.progress_bar.inc(n as u64);
n
})
}
}
#[derive(Debug, Deserialize)]
pub(super) struct BuiltInDeps {
pub perl: Vec<String>,
pub ruby: Vec<String>,
}
#[derive(Debug, Deserialize)]
pub(super) struct CorrectedVals {
pub licenses: Vec<CorrectedLicenses>,
}
#[derive(Debug, Deserialize)]
pub(super) struct CorrectedLicenses {
pub is: String,
pub should: String,
}
#[derive(Debug, Deserialize)]
pub(super) struct NativeDepType {
pub rust: Vec<NativeDeps>,
}
#[derive(Debug, Deserialize)]
pub(super) struct NativeDeps {
pub name: String,
pub dep: String,
}
#[derive(Debug, Deserialize)]
pub(super) struct TomlData {
pub builtin: BuiltInDeps,
pub licenses: Vec<CorrectedLicenses>,
pub native_deps: NativeDepType,
}