Add Printer trait + PrinterHandle enum domain model with polymorphism example
This commit is contained in:
@@ -31,7 +31,21 @@ cargo run
|
||||
src/
|
||||
main.rs Multi-threaded async engine: uplink, discovery, go2rtc watchdog
|
||||
uplink/ Cloud WebSocket client (reconnect, heartbeat, dispatch)
|
||||
adapters/ bambu.rs, prusalink.rs, moonraker.rs printer clients
|
||||
adapters/ bambu.rs, prusalink.rs, moonraker.rs — wire-protocol clients
|
||||
printer/ Domain model: Printer trait + PrinterBase + PrinterHandle enum
|
||||
plate_changer/ Mechanical cycle control + sensor validation
|
||||
discovery/ LAN printer discovery (SSDP / mDNS / static config)
|
||||
```
|
||||
|
||||
`src/adapters/` talks the raw wire protocols (MQTT, FTPS, HTTP, WS).
|
||||
`src/printer/` is the vendor-agnostic domain model layered on top: a
|
||||
`Printer` trait plus one struct per vendor (`BambuPrinter`, `PrusaPrinter`,
|
||||
`KlipperPrinter`) wrapped in a closed `PrinterHandle` enum. Rust has no class
|
||||
inheritance, so this trait+enum combo is what stands in for a
|
||||
`GenericPrinter -> BambuPrinter` hierarchy — composition for shared fields,
|
||||
a trait for shared/overridable behavior, an enum for the closed set of
|
||||
vendors. See `examples/printer_polymorphism.rs`:
|
||||
|
||||
```bash
|
||||
cargo run --example printer_polymorphism
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user