treeboot_core/
metadata.rs1use serde::Serialize;
4use std::sync::OnceLock;
5
6pub const SPEC_VERSION: &str = include_str!(concat!(
8 env!("CARGO_MANIFEST_DIR"),
9 "/assets/spec-version.txt"
10));
11
12pub const TREEBOOT_PACKAGE: &str = "treeboot";
14
15pub const TREEBOOT_VERSION: &str = env!("CARGO_PKG_VERSION");
20
21pub const CONFIG_SCHEMA_JSON: &str = include_str!(concat!(
23 env!("CARGO_MANIFEST_DIR"),
24 "/assets/config.schema.json"
25));
26
27#[must_use]
29pub const fn config_schema_json() -> &'static str {
30 CONFIG_SCHEMA_JSON
31}
32
33#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
35pub struct VersionInfo {
36 pub package: &'static str,
38 pub version: &'static str,
40 pub spec_version: &'static str,
42}
43
44#[must_use]
46pub const fn version_info(package: &'static str, version: &'static str) -> VersionInfo {
47 VersionInfo {
48 package,
49 version,
50 spec_version: SPEC_VERSION,
51 }
52}
53
54#[must_use]
56pub const fn treeboot_version_info() -> VersionInfo {
57 version_info(TREEBOOT_PACKAGE, TREEBOOT_VERSION)
58}
59
60#[must_use]
62pub fn treeboot_version_summary() -> &'static str {
63 static SUMMARY: OnceLock<String> = OnceLock::new();
64
65 SUMMARY.get_or_init(|| format!("{TREEBOOT_VERSION} (spec {SPEC_VERSION})"))
66}