# Language and platform choice ## Decision (implemented) | Decision | Choice | |----------|--------| | Language | **Rust** (single codebase) | | UI | **egui** via **eframe** | | Print protocol | **ESC/POS** (in-tree encoder) | | MVP transport | **USB-serial** via `serialport` | | Packaging | GitLab CI → Linux `.deb`, Windows `.exe` | **Rationale:** One language, small dependency surface, direct control over ESC/POS bytes, native cross-platform UI without a WebView. --- ## Requirements | Requirement | How it is met | |-------------|---------------| | Windows + Linux | Rust + egui + GitLab CI | | Raw USB-serial print (no spooler) | `serialport` crate, 9600 baud | | ESC/POS generation | `src/escpos.rs` (no external ESC/POS crate) | | Live preview | `src/preview.rs` + egui canvas in `app.rs` | | Small distributable | No Chromium/Node; release build uses LTO + strip | | Unit tests | Every module has `#[cfg(test)]` tests | --- ## Dependencies in use | Crate | Role | Why not hand-roll? | |-------|------|-------------------| | `eframe` / `egui` | UI framework | Building a GUI toolkit is out of scope | | `serde` / `serde_json` | `.pos` files | Error-prone to parse/emit JSON manually | | `serialport` | Cross-platform COM/tty access | OS-specific serial APIs differ | | `image` | PNG/JPEG/GIF/BMP decode | Many formats and decoders | | `rfd` | Native file dialogs | OS-native UX expected | **Not used (by design):** `escpos`, `nusb`, `rusb`, `tauri`, TypeScript frontend. --- ## Candidates considered (historical) | Option | Verdict | |--------|---------| | Rust + Tauri 2 + TypeScript | Rejected — two languages, WebView dependency | | Rust + egui | **Selected** | | C# + Avalonia | Viable but weaker serial/ESC/POS ecosystem | | Go + Fyne | Weaker hardware I/O ecosystem | | Python + PyQt | Poor packaging for desktop release | | Electron | Bundle size too large | | C++ + Qt | Slower iteration for a small app | --- ## Platform notes ### Windows - Printers appear as `COMx` after USB-serial driver install. - Release: `posprint.exe` from `cargo build --release`. - CI requires a GitLab runner tagged `windows` + `shell`. ### Linux - Devices: `/dev/ttyUSB*`, `/dev/ttyACM*`, etc. - User must be in the **`dialout`** group. - Release: `.deb` via `cargo deb`; install with `sudo dpkg -i …`. - CI uses `rust:bookworm` image with X11 dev libs for egui. --- ## Deferred | Item | Notes | |------|-------| | USB printer class (bulk) | Would need `nusb` or Windows `usbprint` path | | Bluetooth SPP | Paired devices as serial ports; add when requested | | macOS | Same stack should work; not in CI yet | This document should be updated when transport or UI choices change.