commit 2adb6397bbe7d141b7473f782d0d18ad59e1593c
parent 6dc33b3c07b909f49cece37565ca5ed39193e838
Author: triesap <triesap@radroots.dev>
Date: Mon, 19 Jan 2026 16:58:10 +0000
app: add app key map types
- define datastore key map type aliases
- add key map config container and empty helper
- export key map types from app crate
- add unit test for empty config
Diffstat:
2 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/app/src/config.rs b/app/src/config.rs
@@ -0,0 +1,38 @@
+#![forbid(unsafe_code)]
+
+use std::collections::BTreeMap;
+
+pub type AppDatastoreKeyParam = fn(&str) -> String;
+pub type AppDatastoreKeyMap = BTreeMap<&'static str, &'static str>;
+pub type AppDatastoreKeyParamMap = BTreeMap<&'static str, AppDatastoreKeyParam>;
+pub type AppDatastoreKeyObjMap = BTreeMap<&'static str, &'static str>;
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct AppKeyMapConfig {
+ pub key_map: AppDatastoreKeyMap,
+ pub param_map: AppDatastoreKeyParamMap,
+ pub obj_map: AppDatastoreKeyObjMap,
+}
+
+impl AppKeyMapConfig {
+ pub fn empty() -> Self {
+ Self {
+ key_map: BTreeMap::new(),
+ param_map: BTreeMap::new(),
+ obj_map: BTreeMap::new(),
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::AppKeyMapConfig;
+
+ #[test]
+ fn key_map_config_defaults_empty() {
+ let config = AppKeyMapConfig::empty();
+ assert!(config.key_map.is_empty());
+ assert!(config.param_map.is_empty());
+ assert!(config.obj_map.is_empty());
+ }
+}
diff --git a/app/src/lib.rs b/app/src/lib.rs
@@ -2,11 +2,19 @@
mod app;
mod context;
+mod config;
mod init;
mod entry;
pub use app::App;
pub use context::{app_context, AppContext};
+pub use config::{
+ AppDatastoreKeyMap,
+ AppDatastoreKeyObjMap,
+ AppDatastoreKeyParam,
+ AppDatastoreKeyParamMap,
+ AppKeyMapConfig,
+};
pub use init::{
app_init_backends,
app_init_has_completed,