use serde::Serialize;
use std::sync::OnceLock;
pub const SPEC_VERSION: &str = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/assets/spec-version.txt"
));
pub const TREEBOOT_PACKAGE: &str = "treeboot";
pub const TREEBOOT_VERSION: &str = env!("CARGO_PKG_VERSION");
pub const CONFIG_SCHEMA_JSON: &str = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/assets/config.schema.json"
));
#[must_use]
pub const fn config_schema_json() -> &'static str {
CONFIG_SCHEMA_JSON
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
pub struct VersionInfo {
pub package: &'static str,
pub version: &'static str,
pub spec_version: &'static str,
}
#[must_use]
pub const fn version_info(package: &'static str, version: &'static str) -> VersionInfo {
VersionInfo {
package,
version,
spec_version: SPEC_VERSION,
}
}
#[must_use]
pub const fn treeboot_version_info() -> VersionInfo {
version_info(TREEBOOT_PACKAGE, TREEBOOT_VERSION)
}
#[must_use]
pub fn treeboot_version_summary() -> &'static str {
static SUMMARY: OnceLock<String> = OnceLock::new();
SUMMARY.get_or_init(|| format!("{TREEBOOT_VERSION} (spec {SPEC_VERSION})"))
}