asked the clanker to change the arcidecture a bit

This commit is contained in:
2026-09-09 15:50:07 +01:00
parent 3490af52e4
commit b9c7e73824
15 changed files with 185 additions and 74 deletions
+12
View File
@@ -0,0 +1,12 @@
[package]
name = "modules"
version.workspace = true
edition.workspace = true
[lib]
name = "modules"
path = "src/lib.rs"
[dependencies]
common = { path = "../common" }
module_clock = { package = "module-clock", path = "clock" }
+2 -1
View File
@@ -9,5 +9,6 @@ path = "src/lib.rs"
[dependencies]
common = { path = "../../common" }
service_datatime = { package = "service-datatime", path = "../../services/datatime" }
iced = { workspace = true }
thiserror = { workspace = true }
toml = { workspace = true }
+16
View File
@@ -11,6 +11,14 @@ use common::{BarModule, ClockKind, ClockPayload, ModuleEffect, ModuleMsg, Servic
const POPUP_W: u32 = 360;
const POPUP_H: u32 = 160;
/// Errors digesting the `module.clock` config table.
#[derive(Debug, thiserror::Error)]
pub enum ClockError {
/// Config value was present but not a bool.
#[error("module.clock.{0} must be a bool")]
NotBool(&'static str),
}
/// A module-local message for the clock.
#[derive(Clone)]
pub enum ClockMsg {
@@ -100,4 +108,12 @@ impl BarModule for Clock {
fn popup_size(&self) -> Option<(u32, u32)> {
Some((POPUP_W, POPUP_H))
}
fn config(&mut self, config: toml::Table) -> Result<(), Box<dyn std::error::Error>> {
if let toml::Value::Boolean(e) = config["format"] {
if e {
self.show_seconds = true;
};
}
Ok(())
}
}
+10
View File
@@ -0,0 +1,10 @@
//! Bar module registry: constructs every enabled module. Adding a module is
//! a new crate under `crates/modules/` plus one entry in `all()` — core
//! never changes.
use common::BarModule;
/// One instance of every enabled module, ready to insert by `id()`.
pub fn all() -> Vec<Box<dyn BarModule>> {
vec![Box::new(module_clock::Clock::new())]
}