Skip to main content

entrenar/sovereign/distribution/
component.rs

1//! Individual component manifest
2
3use serde::{Deserialize, Serialize};
4
5/// Individual component manifest
6#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7pub struct ComponentManifest {
8    /// Component name
9    pub name: String,
10    /// Component version
11    pub version: String,
12    /// Crate name on crates.io
13    pub crate_name: String,
14    /// Enabled features
15    pub features: Vec<String>,
16}
17
18impl ComponentManifest {
19    /// Create a new component manifest
20    pub fn new(
21        name: impl Into<String>,
22        version: impl Into<String>,
23        crate_name: impl Into<String>,
24    ) -> Self {
25        Self {
26            name: name.into(),
27            version: version.into(),
28            crate_name: crate_name.into(),
29            features: Vec::new(),
30        }
31    }
32
33    /// Add features to the component
34    pub fn with_features(mut self, features: impl IntoIterator<Item = impl Into<String>>) -> Self {
35        self.features = features.into_iter().map(Into::into).collect();
36        self
37    }
38
39    /// Create component for entrenar-core
40    pub fn entrenar_core(version: &str) -> Self {
41        Self::new("entrenar-core", version, "entrenar")
42    }
43
44    /// Create component for trueno
45    pub fn trueno(version: &str) -> Self {
46        Self::new("trueno", version, "trueno")
47    }
48
49    /// Create component for aprender
50    pub fn aprender(version: &str) -> Self {
51        Self::new("aprender", version, "aprender")
52    }
53
54    /// Create component for renacer
55    pub fn renacer(version: &str) -> Self {
56        Self::new("renacer", version, "renacer")
57    }
58}