Files
k-frame/crates/protocol/src/wire.rs
Gabriel Kaszewski 7001b5e911 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
2026-06-19 18:12:50 +02:00

120 lines
2.5 KiB
Rust

use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum WireValue {
Null,
Bool(bool),
Number(f64),
String(String),
Array(Vec<WireValue>),
Object(BTreeMap<String, WireValue>),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum WireWidgetError {
SourceUnavailable,
ExtractionFailed,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WireKeyValue {
pub key: String,
pub value: WireValue,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WireWidgetState {
pub data: Vec<WireKeyValue>,
pub error: Option<WireWidgetError>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum WireDisplayHintKind {
IconValue,
TextBlock,
KeyValue,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum WireHAlign {
Left,
Center,
Right,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum WireVAlign {
Top,
Middle,
Bottom,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WireDisplayHint {
pub kind: WireDisplayHintKind,
pub h_align: WireHAlign,
pub v_align: WireVAlign,
}
impl WireDisplayHint {
pub fn new(kind: WireDisplayHintKind) -> Self {
Self {
kind,
h_align: WireHAlign::Left,
v_align: WireVAlign::Top,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum WireSizing {
Fixed(u16),
Flex(u8),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum WireDirection {
Row,
Column,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum WireJustifyContent {
Start,
Center,
End,
SpaceBetween,
SpaceEvenly,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum WireAlignItems {
Start,
Center,
End,
Stretch,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WireContainerNode {
pub direction: WireDirection,
pub gap: u8,
pub padding: u8,
pub justify_content: WireJustifyContent,
pub align_items: WireAlignItems,
pub children: Vec<WireLayoutChild>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WireLayoutChild {
pub sizing: WireSizing,
pub node: WireLayoutNode,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum WireLayoutNode {
Container(WireContainerNode),
Leaf(u16),
}