1use serde_derive::Deserialize;
17use std::io::Read;
18
19pub struct TmplBuilder {
21 pub pkg_name: String,
22 pub pkg_type: Option<PkgType>,
23 pub pkg_info: Option<PkgInfo>,
24}
25
26pub struct Template {
27 pub inner: String,
28 pub name: String,
29}
30
31impl Read for Template {
32 fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
33 self.inner.as_bytes().read(buf)
34 }
35}
36
37#[derive(Copy, Clone, Eq, Ord, PartialOrd, Hash, Debug, PartialEq)]
39pub enum PkgType {
40 Crate,
41 Gem,
42 PerlDist,
43}
44
45#[derive(Clone, Eq, Ord, PartialOrd, Hash, Default, Debug, PartialEq)]
47pub struct Dependencies {
48 pub host: Option<Vec<String>>,
49 pub make: Option<Vec<String>>,
50 pub run: Option<Vec<String>>,
51}
52
53#[derive(Clone, Eq, Ord, PartialOrd, Hash, Default, Debug, PartialEq)]
55pub struct PkgInfo {
56 pub pkg_name: String,
57 pub version: String,
58 pub description: Option<String>,
59 pub homepage: String,
60 pub license: Option<Vec<String>>,
61 pub dependencies: Option<Dependencies>,
62 pub sha: String,
63 pub download_url: Option<String>,
64}
65
66pub(super) struct DownloadProgress<R> {
67 pub inner: R,
68 pub progress_bar: indicatif::ProgressBar,
69}
70
71impl<R: std::io::Read> std::io::Read for DownloadProgress<R> {
72 fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
73 self.inner.read(buf).map(|n| {
74 self.progress_bar.inc(n as u64);
75 n
76 })
77 }
78}
79
80#[derive(Debug, Deserialize)]
81pub(super) struct BuiltInDeps {
82 pub perl: Vec<String>,
83 pub ruby: Vec<String>,
84}
85
86#[derive(Debug, Deserialize)]
87pub(super) struct CorrectedVals {
88 pub licenses: Vec<CorrectedLicenses>,
89}
90
91#[derive(Debug, Deserialize)]
92pub(super) struct CorrectedLicenses {
93 pub is: String,
94 pub should: String,
95}
96
97#[derive(Debug, Deserialize)]
98pub(super) struct NativeDepType {
99 pub rust: Vec<NativeDeps>,
100}
101
102#[derive(Debug, Deserialize)]
103pub(super) struct NativeDeps {
104 pub name: String,
105 pub dep: String,
106}
107
108#[derive(Debug, Deserialize)]
109pub(super) struct TomlData {
110 pub builtin: BuiltInDeps,
111 pub licenses: Vec<CorrectedLicenses>,
112 pub native_deps: NativeDepType,
113}