Simplify boilerplate for learning: drop real protocol code, minimal main.rs
Removed adapters/ (rumqttc MQTT, suppaftp FTPS, reqwest HTTP), plate_changer/ (tokio-serial), discovery/, and cache.rs (rusqlite) — src/printer/ already covers 'talk to a printer' as simple stubs, so keeping a second, more complex version alongside it was redundant. main.rs goes from 6 concurrent tasks to 2 (uplink + go2rtc). uplink/ drops channels, jitter, and Send-bound futures. Verified with cargo build + cargo run --example printer_polymorphism.
This commit is contained in:
+6
-31
@@ -1,42 +1,17 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Messages sent from this gateway up to `continuum-backend`'s `/ws/edge/v1` route.
|
||||
/// What this gateway sends up to `continuum-backend`'s `/ws/edge/v1` route.
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
pub enum ClientMessage {
|
||||
Hello {
|
||||
gateway_id: String,
|
||||
farm_id: String,
|
||||
token: String,
|
||||
version: &'static str,
|
||||
},
|
||||
Heartbeat {
|
||||
seq: u64,
|
||||
},
|
||||
Telemetry {
|
||||
printer_id: String,
|
||||
payload: serde_json::Value,
|
||||
},
|
||||
TaskResult {
|
||||
task_id: String,
|
||||
ok: bool,
|
||||
error: Option<String>,
|
||||
},
|
||||
Hello { gateway_id: String, farm_id: String, token: String },
|
||||
Heartbeat { seq: u64 },
|
||||
}
|
||||
|
||||
/// Messages received from `continuum-backend` over the same connection.
|
||||
/// What `continuum-backend` sends back over the same connection.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
pub enum ServerMessage {
|
||||
HelloAck {
|
||||
session_id: String,
|
||||
},
|
||||
HeartbeatAck {
|
||||
seq: u64,
|
||||
},
|
||||
Task {
|
||||
task_id: String,
|
||||
kind: String,
|
||||
payload: serde_json::Value,
|
||||
},
|
||||
HelloAck { session_id: String },
|
||||
HeartbeatAck { seq: u64 },
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user