use serde::{Deserialize, Serialize};
use std::fmt;
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum DeploymentProfile {
profile_mobile,
profile_browser,
profile_edge,
profile_fog,
profile_iot,
}
impl DeploymentProfile {
pub fn id(&self) -> &'static str {
match self {
Self::profile_mobile => "profile-mobile",
Self::profile_browser => "profile-browser",
Self::profile_edge => "profile-edge",
Self::profile_fog => "profile-fog",
Self::profile_iot => "profile-iot",
}
}
pub fn label(&self) -> &'static str {
match self {
Self::profile_mobile => "Mobile",
Self::profile_browser => "Browser",
Self::profile_edge => "Edge",
Self::profile_fog => "Fog",
Self::profile_iot => "IoT",
}
}
pub fn size_target_mb(&self) -> f64 {
match self {
Self::profile_mobile => 0.5,
Self::profile_browser => 2.78,
Self::profile_edge => 1.5,
Self::profile_fog => 2.0,
Self::profile_iot => 1.0,
}
}
pub fn all() -> &'static [Self] {
&[
Self::profile_mobile,
Self::profile_browser,
Self::profile_edge,
Self::profile_fog,
Self::profile_iot,
]
}
}
impl fmt::Display for DeploymentProfile {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.label())
}
}