BlueGit

timfa posprint

Files

posprint / docs / LANGUAGE-CHOICE.md

LANGUAGE-CHOICE.md

LANGUAGE-CHOICE.md 2.6 KiB Download Raw

Language and platform choice

Decision (implemented)

DecisionChoice
LanguageRust (single codebase)
UIegui via eframe
Print protocolESC/POS (in-tree encoder)
MVP transportUSB-serial via serialport
PackagingGitLab 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

RequirementHow it is met
Windows + LinuxRust + egui + GitLab CI
Raw USB-serial print (no spooler)serialport crate, 9600 baud
ESC/POS generationsrc/escpos.rs (no external ESC/POS crate)
Live previewsrc/preview.rs + egui canvas in app.rs
Small distributableNo Chromium/Node; release build uses LTO + strip
Unit testsEvery module has #[cfg(test)] tests

---

Dependencies in use

CrateRoleWhy not hand-roll?
eframe / eguiUI frameworkBuilding a GUI toolkit is out of scope
serde / serde_json.pos filesError-prone to parse/emit JSON manually
serialportCross-platform COM/tty accessOS-specific serial APIs differ
imagePNG/JPEG/GIF/BMP decodeMany formats and decoders
rfdNative file dialogsOS-native UX expected

Not used (by design): escpos, nusb, rusb, tauri, TypeScript frontend.

---

Candidates considered (historical)

OptionVerdict
Rust + Tauri 2 + TypeScriptRejected — two languages, WebView dependency
Rust + eguiSelected
C# + AvaloniaViable but weaker serial/ESC/POS ecosystem
Go + FyneWeaker hardware I/O ecosystem
Python + PyQtPoor packaging for desktop release
ElectronBundle size too large
C++ + QtSlower 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

ItemNotes
USB printer class (bulk)Would need nusb or Windows usbprint path
Bluetooth SPPPaired devices as serial ports; add when requested
macOSSame stack should work; not in CI yet

This document should be updated when transport or UI choices change.

Source
1# Language and platform choice
2
3## Decision (implemented)
4
5| Decision | Choice |
6|----------|--------|
7| Language | **Rust** (single codebase) |
8| UI | **egui** via **eframe** |
9| Print protocol | **ESC/POS** (in-tree encoder) |
10| MVP transport | **USB-serial** via `serialport` |
11| Packaging | GitLab CI → Linux `.deb`, Windows `.exe` |
12
13**Rationale:** One language, small dependency surface, direct control over ESC/POS bytes, native cross-platform UI without a WebView.
14
15---
16
17## Requirements
18
19| Requirement | How it is met |
20|-------------|---------------|
21| Windows + Linux | Rust + egui + GitLab CI |
22| Raw USB-serial print (no spooler) | `serialport` crate, 9600 baud |
23| ESC/POS generation | `src/escpos.rs` (no external ESC/POS crate) |
24| Live preview | `src/preview.rs` + egui canvas in `app.rs` |
25| Small distributable | No Chromium/Node; release build uses LTO + strip |
26| Unit tests | Every module has `#[cfg(test)]` tests |
27
28---
29
30## Dependencies in use
31
32| Crate | Role | Why not hand-roll? |
33|-------|------|-------------------|
34| `eframe` / `egui` | UI framework | Building a GUI toolkit is out of scope |
35| `serde` / `serde_json` | `.pos` files | Error-prone to parse/emit JSON manually |
36| `serialport` | Cross-platform COM/tty access | OS-specific serial APIs differ |
37| `image` | PNG/JPEG/GIF/BMP decode | Many formats and decoders |
38| `rfd` | Native file dialogs | OS-native UX expected |
39
40**Not used (by design):** `escpos`, `nusb`, `rusb`, `tauri`, TypeScript frontend.
41
42---
43
44## Candidates considered (historical)
45
46| Option | Verdict |
47|--------|---------|
48| Rust + Tauri 2 + TypeScript | Rejected — two languages, WebView dependency |
49| Rust + egui | **Selected** |
50| C# + Avalonia | Viable but weaker serial/ESC/POS ecosystem |
51| Go + Fyne | Weaker hardware I/O ecosystem |
52| Python + PyQt | Poor packaging for desktop release |
53| Electron | Bundle size too large |
54| C++ + Qt | Slower iteration for a small app |
55
56---
57
58## Platform notes
59
60### Windows
61
62- Printers appear as `COMx` after USB-serial driver install.
63- Release: `posprint.exe` from `cargo build --release`.
64- CI requires a GitLab runner tagged `windows` + `shell`.
65
66### Linux
67
68- Devices: `/dev/ttyUSB*`, `/dev/ttyACM*`, etc.
69- User must be in the **`dialout`** group.
70- Release: `.deb` via `cargo deb`; install with `sudo dpkg -i …`.
71- CI uses `rust:bookworm` image with X11 dev libs for egui.
72
73---
74
75## Deferred
76
77| Item | Notes |
78|------|-------|
79| USB printer class (bulk) | Would need `nusb` or Windows `usbprint` path |
80| Bluetooth SPP | Paired devices as serial ports; add when requested |
81| macOS | Same stack should work; not in CI yet |
82
83This document should be updated when transport or UI choices change.