use serde::Serialize;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum Scope {
Function,
File,
Project,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum Applicability {
LanguageIndependent,
PartiallyLanguageDependent,
LanguageSpecific,
}
#[derive(Debug, Clone, PartialEq, Serialize)]
pub struct MetricDefinition {
pub id: &'static str,
pub name: &'static str,
pub description: &'static str,
pub definition: &'static str,
pub scopes: &'static [Scope],
pub input: &'static str,
pub calculation: &'static str,
pub unit: &'static str,
pub applicability: Applicability,
pub limitations: &'static str,
pub reference: &'static str,
}
pub const DEFINITION_VERSION: &str = "0.1.0";
impl Scope {
pub fn as_str(&self) -> &'static str {
match self {
Scope::Function => "function",
Scope::File => "file",
Scope::Project => "project",
}
}
}
impl Applicability {
pub fn as_str(&self) -> &'static str {
match self {
Applicability::LanguageIndependent => "language_independent",
Applicability::PartiallyLanguageDependent => "partially_language_dependent",
Applicability::LanguageSpecific => "language_specific",
}
}
}