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
/// Trait for build system outputs.
///
/// This trait is implemented by types that represent outputs from a build system,
/// such as binary packages, library packages, etc.
pub trait Output: std::fmt::Debug {
/// Get the family of this output (e.g., "binary", "python-package", etc.).
///
/// # Returns
/// A string identifying the output type family
fn family(&self) -> &'static str;
/// Get the dependencies declared by this output.
///
/// # Returns
/// A list of dependency names
fn get_declared_dependencies(&self) -> Vec<String>;
}
#[derive(Debug)]
/// Output representing a binary executable.
pub struct BinaryOutput(pub String);
impl BinaryOutput {
/// Create a new binary output.
///
/// # Arguments
/// * `name` - Name of the binary
///
/// # Returns
/// A new BinaryOutput instance
pub fn new(name: &str) -> Self {
BinaryOutput(name.to_owned())
}
}
impl Output for BinaryOutput {
fn family(&self) -> &'static str {
"binary"
}
fn get_declared_dependencies(&self) -> Vec<String> {
vec![]
}
}
#[derive(Debug)]
/// Output representing a Python package.
pub struct PythonPackageOutput {
/// Name of the Python package.
pub name: String,
/// Optional version of the Python package.
pub version: Option<String>,
}
impl PythonPackageOutput {
/// Create a new Python package output.
///
/// # Arguments
/// * `name` - Name of the Python package
/// * `version` - Optional version of the Python package
///
/// # Returns
/// A new PythonPackageOutput instance
pub fn new(name: &str, version: Option<&str>) -> Self {
PythonPackageOutput {
name: name.to_owned(),
version: version.map(|s| s.to_owned()),
}
}
}
impl Output for PythonPackageOutput {
fn family(&self) -> &'static str {
"python-package"
}
fn get_declared_dependencies(&self) -> Vec<String> {
vec![]
}
}
#[derive(Debug)]
/// Output representing an R package.
pub struct RPackageOutput {
/// Name of the R package.
pub name: String,
}
impl RPackageOutput {
/// Create a new R package output.
///
/// # Arguments
/// * `name` - Name of the R package
///
/// # Returns
/// A new RPackageOutput instance
pub fn new(name: &str) -> Self {
RPackageOutput {
name: name.to_owned(),
}
}
}
impl Output for RPackageOutput {
fn family(&self) -> &'static str {
"r-package"
}
fn get_declared_dependencies(&self) -> Vec<String> {
vec![]
}
}