arch: split ConfigRepository, extract polling, consolidate conversions, decouple protocol
- Value↔JSON: From impls on domain Value behind `json` feature, delete 4 duplicate converters - ConfigRepository split into ConfigRepository (12), UserRepository (3), WidgetStateCache (2) - polling orchestration moved from bootstrap to application::polling_service - WidgetRenderer in client-domain owns scroll/cache, both clients use it - network loop consolidated into client-application::run_connection_loop - protocol crate drops domain dep, Wire↔Domain conversions move to adapters
This commit is contained in:
@@ -126,32 +126,10 @@ where
|
||||
{
|
||||
match state.widget_states.get_widget_state(id).await {
|
||||
Some(ws) => {
|
||||
let map: serde_json::Map<String, serde_json::Value> = ws
|
||||
.data
|
||||
.iter()
|
||||
.map(|(k, v)| (k.clone(), domain_value_to_json(v)))
|
||||
.collect();
|
||||
let map: serde_json::Map<String, serde_json::Value> =
|
||||
ws.data.iter().map(|(k, v)| (k.clone(), v.into())).collect();
|
||||
Ok(Json(serde_json::Value::Object(map)))
|
||||
}
|
||||
None => Err(StatusCode::NOT_FOUND),
|
||||
}
|
||||
}
|
||||
|
||||
fn domain_value_to_json(v: &domain::Value) -> serde_json::Value {
|
||||
match v {
|
||||
domain::Value::Null => serde_json::Value::Null,
|
||||
domain::Value::Bool(b) => serde_json::Value::Bool(*b),
|
||||
domain::Value::Number(n) => serde_json::json!(n),
|
||||
domain::Value::String(s) => serde_json::Value::String(s.clone()),
|
||||
domain::Value::Array(arr) => {
|
||||
serde_json::Value::Array(arr.iter().map(domain_value_to_json).collect())
|
||||
}
|
||||
domain::Value::Object(obj) => {
|
||||
let map = obj
|
||||
.iter()
|
||||
.map(|(k, v)| (k.clone(), domain_value_to_json(v)))
|
||||
.collect();
|
||||
serde_json::Value::Object(map)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user