- Rust 81.4%
- JavaScript 6.5%
- HTML 6.1%
- CSS 5.1%
- Just 0.9%
Extracted from the rust-port branch of the diary repo (commit 85746b3), promoted to the repository root. |
||
|---|---|---|
| src | ||
| static | ||
| templates | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| justfile | ||
| README.md | ||
Claras Tagebuch — Rust port
A drop-in Rust reimplementation of the Go diary server. It targets the same
MariaDB schema, the same on-disk media layout, and the same DIARY_*
environment as the Go binary, so it can replace it without data migration.
Stack
| Concern | Crate |
|---|---|
| HTTP / routing / middleware | axum 0.8 + tower / tower-http |
| Async runtime | tokio |
| Database | sqlx (MySQL, runtime queries, rustls) |
| Templates | askama (compile-time, embedded) |
| Static assets | rust-embed + SHA-256 fingerprinting |
lettre (SMTP/STARTTLS, rustls) |
|
| Logging | tracing (JSON) |
Build / test / run
just test # cargo test (unit tests + read-only DB integration tests)
just run # run locally on :3108 against ../media
just dist # optimized binary at target/release/diary
just deploy # scp + systemctl restart (same unit/path as the Go server)
The integration tests in src/entry.rs connect to the local diary database
using the default dev credentials and skip cleanly if it is unreachable.
Drop-in notes / deliberate differences
DIARY_DSNstays in go-sql-driver form (e.g.diary:diary@/diary?parseTime=true) and is translated to discrete connection fields at startup (settings::parse_dsn), so the env contract is unchanged.- Timestamps.
TIMESTAMPcolumns are read/written aschrono::DateTime<Utc>and the DB session is pinned to+00:00(db::connect), keeping the app cleanly UTC-consistent. (The Go app relied on go-sql-driver'sloc=UTClabeling; sessions/nonces written by the old binary may read back skewed by the server's local UTC offset, but they are short-lived and re-minted after cutover.) - Behavioural parity preserved (not "fixed"):
redirectalways emits 303; the thumbnail Content-Type is the quirkyapplication/jpeg; entry positions are spaced by 10. - The Go repository code generator is dropped — the four entities have
hand-written
sqlxrepositories behind the same trait seams used for mocking.
Static binary
just dist produces a fully static binary (like the Go CGO_ENABLED=0 build) at
target/x86_64-unknown-linux-musl/release/diary — no runtime library
dependencies, so it deploys to any x86-64 Linux host.
Requirements: the musl std (rust-musl) and gcc. ring (rustls's crypto) has
C/asm, so its build is pointed at gcc via
CC_x86_64_unknown_linux_musl=gcc (set automatically by the dist recipe); the
objects link against the musl libc.a bundled with the Rust musl std.