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
//! Properties-related to Abscissa as an application framework
//!
//! These are presently not very configurable, but could be made to be.

use super::cargo;
pub use semver::Version;
use serde::{Deserialize, Serialize};

/// Default Cargo features to enable in the `abscissa` crate
const DEFAULT_CARGO_FEATURES: &[&str] = &["application", "signals", "secrets", "time"];

/// Abscissa framework-related properties
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Properties {
    /// Abscissa version
    pub version: Version,

    /// Cargo features to enable
    pub cargo_features: Vec<cargo::Feature>,
}

impl Properties {
    /// Initialize Abscissa framework properties
    pub fn new(version: &str) -> Self {
        Self {
            version: version.parse().unwrap(),
            cargo_features: DEFAULT_CARGO_FEATURES
                .iter()
                .map(|feature| feature.parse::<cargo::Feature>().unwrap())
                .collect(),
        }
    }
}