Signal-System mit Inky und KV-Store

This commit is contained in:
2026-06-12 22:36:43 +02:00
parent ff80b3cc0f
commit 97eff4f9eb
16 changed files with 1432 additions and 1 deletions
+26
View File
@@ -0,0 +1,26 @@
//! Asset-Pfadauflösung: Distribution-Layout (assets/ neben der Binary)
//! oder Dev-Layout (assets/ im CWD, also Projektroot bei `cargo run`).
use std::path::PathBuf;
use std::sync::OnceLock;
static BASE: OnceLock<PathBuf> = OnceLock::new();
fn base() -> &'static PathBuf {
BASE.get_or_init(|| {
if let Ok(exe) = std::env::current_exe() {
if let Some(dir) = exe.parent() {
if dir.join("assets").exists() {
return dir.to_path_buf();
}
}
}
std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."))
})
}
/// Wandelt einen relativen Pfad wie `"assets/signals.toml"` in einen
/// absoluten Pfad relativ zum Asset-Basisverzeichnis um.
pub fn path(rel: &str) -> String {
base().join(rel).to_string_lossy().into_owned()
}