add all crates: domain, protocol, application, client, adapters, ESP32 firmware
Server: domain (entities, value objects, ports), protocol (postcard wire types), application (config service, data projection), adapters (config-memory, tcp-server), bootstrap (composition root with fake data). Client: client-domain (layout engine, render tree, HAL ports), client-application (message handling, repaint commands), adapters (tcp-client, display-terminal), client-desktop (end-to-end working). ESP32: client-esp32 firmware with ILI9341 display over SPI, WiFi networking. Display test verified on hardware — landscape orientation, text rendering works. 60 workspace tests, all passing.
This commit is contained in:
42
crates/application/src/data_projection.rs
Normal file
42
crates/application/src/data_projection.rs
Normal file
@@ -0,0 +1,42 @@
|
||||
use std::collections::HashMap;
|
||||
use domain::{DataSourceId, Value, WidgetConfig, WidgetId, WidgetState};
|
||||
|
||||
pub struct DataProjection {
|
||||
current: HashMap<WidgetId, WidgetState>,
|
||||
}
|
||||
|
||||
impl DataProjection {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
current: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn apply_poll_result(
|
||||
&mut self,
|
||||
data_source_id: DataSourceId,
|
||||
raw: &Value,
|
||||
widget_configs: &[WidgetConfig],
|
||||
) -> Vec<(WidgetId, WidgetState)> {
|
||||
let mut changed = Vec::new();
|
||||
|
||||
for config in widget_configs {
|
||||
if config.data_source_id != data_source_id {
|
||||
continue;
|
||||
}
|
||||
|
||||
let new_state = config.extract(raw);
|
||||
|
||||
let is_changed = self.current
|
||||
.get(&config.id)
|
||||
.map_or(true, |prev| *prev != new_state);
|
||||
|
||||
if is_changed {
|
||||
self.current.insert(config.id, new_state.clone());
|
||||
changed.push((config.id, new_state));
|
||||
}
|
||||
}
|
||||
|
||||
changed
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user