msg type -> wire::push() -> update handle wire into module/service/ect

This commit is contained in:
2026-09-12 15:04:06 +01:00
parent 539c80cda9
commit 27ec2b90a6
24 changed files with 411 additions and 204 deletions
+20 -6
View File
@@ -1,10 +1,11 @@
use std::collections::BTreeMap;
use std::collections::{BTreeMap, BTreeSet};
use iced::window;
use common::{BarModule, Service};
use common::{BarModule, Inbox, Service};
use toml::Table;
/// Application state: module registry + popup bookkeeping.
/// Application state: module registry, routing, popup bookkeeping.
pub(crate) struct Bar {
/// Module whose popup is open; None = closed.
pub(crate) active_popup: Option<String>,
@@ -14,22 +15,35 @@ pub(crate) struct Bar {
pub(crate) popup_id: Option<window::Id>,
/// Fan-out routing table: module id -> services it wants.
pub(crate) routes: BTreeMap<&'static str, Vec<Service>>,
/// One inbound mailbox per running service, keyed by route key. Modules
/// send here (`Target::Service`) to talk to a running service.
pub(crate) inputs: BTreeMap<&'static str, Inbox>,
}
impl Bar {
pub(crate) fn new() -> Self {
pub(crate) fn new(modules_config_table: &Table) -> Self {
// Registry owns construction: adding a module never edits this file.
let modules: BTreeMap<&'static str, Box<dyn BarModule>> =
modules::all().into_iter().map(|m| (m.id(), m)).collect();
let routes = modules
modules::all(modules_config_table.clone())
.into_iter()
.map(|m| (m.id(), m))
.collect();
let routes: BTreeMap<&'static str, Vec<Service>> = modules
.iter()
.map(|(id, module)| (*id, module.services()))
.collect();
// One inbox per distinct service any module wants.
let wanted: BTreeSet<&'static str> = routes.values().flatten().map(|s| s.0).collect();
let inputs = wanted
.into_iter()
.map(|key| (key, Inbox::new(key)))
.collect();
Self {
active_popup: None,
modules,
popup_id: None,
routes,
inputs,
}
}
}