wasm4pm 26.6.10

High-performance process mining algorithms in WebAssembly for JavaScript/TypeScript
Documentation
// Auto-generated by CodeManufactory from wasm4pm ontology
// DO NOT EDIT — regenerate via: ostar manufacture wasm4pm

use serde::{Deserialize, Serialize};
use std::fmt;

/// Deployment profiles from wasm4pm-core.nt.
#[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",
        }
    }

    /// Maximum binary size target in MB for this profile.
    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())
    }
}