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:
2026-08-28 18:22:38 +00:00
parent 5705f36c01
commit d0a17ee50e
16 changed files with 80 additions and 799 deletions
-44
View File
@@ -1,44 +0,0 @@
use std::time::Duration;
use serde::{Deserialize, Serialize};
use tracing::{debug, info};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PrinterVendor {
Bambu,
Prusa,
Klipper,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DiscoveredPrinter {
pub vendor: PrinterVendor,
pub host: String,
pub serial: Option<String>,
}
/// Periodically sweeps the LAN for printers (SSDP for Bambu, mDNS for
/// PrusaLink/Moonraker) and reports newly-seen devices upstream.
///
/// This is intentionally a stub: production discovery would bind a UDP
/// multicast socket per protocol. It's structured so each protocol's probe
/// can be dropped in independently without touching the polling loop.
pub async fn run(interval: Duration, tx: tokio::sync::mpsc::Sender<DiscoveredPrinter>) {
let mut ticker = tokio::time::interval(interval);
loop {
ticker.tick().await;
debug!("running LAN discovery sweep");
for printer in sweep().await {
info!(host = %printer.host, ?printer.vendor, "discovered printer");
if tx.send(printer).await.is_err() {
return;
}
}
}
}
async fn sweep() -> Vec<DiscoveredPrinter> {
// TODO: SSDP probe (Bambu), mDNS `_prusalink._tcp` / `_moonraker._tcp` probes.
Vec::new()
}