app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

commit 8dae02bdff46a91b2b329699ae63ea33e55dc2b0
parent d318d2c48fa8daaa078d4b541a088ecb2fddbf50
Author: triesap <triesap@radroots.dev>
Date:   Mon, 19 Jan 2026 17:46:18 +0000

app: add bootstrap data types

- add config and app data structs with defaults
- define AppConfigRole enum with default
- re-export bootstrap data types from app crate
- add unit tests for default values

Diffstat:
Mapp/Cargo.toml | 1+
Aapp/src/data.rs | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mapp/src/lib.rs | 2++
3 files changed, 86 insertions(+), 0 deletions(-)

diff --git a/app/Cargo.toml b/app/Cargo.toml @@ -13,6 +13,7 @@ crate-type = ["cdylib", "rlib"] leptos = { workspace = true, features = ["csr"] } wasm-bindgen.workspace = true radroots-app-core = { path = "../crates/core" } +serde.workspace = true [dev-dependencies] futures.workspace = true diff --git a/app/src/data.rs b/app/src/data.rs @@ -0,0 +1,83 @@ +#![forbid(unsafe_code)] + +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +pub enum AppConfigRole { + Public, +} + +impl Default for AppConfigRole { + fn default() -> Self { + AppConfigRole::Public + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct AppConfigData { + pub nostr_public_key: Option<String>, + pub nostr_profile: Option<String>, + pub role: Option<AppConfigRole>, + pub nip05_request: Option<bool>, + pub nip05_key: Option<String>, +} + +impl Default for AppConfigData { + fn default() -> Self { + Self { + nostr_public_key: None, + nostr_profile: None, + role: None, + nip05_request: None, + nip05_key: None, + } + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct AppAppData { + pub active_key: String, + pub role: AppConfigRole, + pub eula_date: String, + pub nip05_key: Option<String>, +} + +impl Default for AppAppData { + fn default() -> Self { + Self { + active_key: String::new(), + role: AppConfigRole::default(), + eula_date: String::new(), + nip05_key: None, + } + } +} + +#[cfg(test)] +mod tests { + use super::{AppAppData, AppConfigData, AppConfigRole}; + + #[test] + fn config_role_defaults_to_public() { + assert_eq!(AppConfigRole::default(), AppConfigRole::Public); + } + + #[test] + fn config_data_defaults_empty() { + let data = AppConfigData::default(); + assert!(data.nostr_public_key.is_none()); + assert!(data.nostr_profile.is_none()); + assert!(data.role.is_none()); + assert!(data.nip05_request.is_none()); + assert!(data.nip05_key.is_none()); + } + + #[test] + fn app_data_defaults_empty() { + let data = AppAppData::default(); + assert_eq!(data.active_key, ""); + assert_eq!(data.role, AppConfigRole::Public); + assert_eq!(data.eula_date, ""); + assert!(data.nip05_key.is_none()); + } +} diff --git a/app/src/lib.rs b/app/src/lib.rs @@ -3,11 +3,13 @@ mod app; mod context; mod config; +mod data; mod init; mod entry; pub use app::App; pub use context::{app_context, AppContext}; +pub use data::{AppAppData, AppConfigData, AppConfigRole}; pub use config::{ app_config_default, app_config_from_env,