No description
  • Rust 81.4%
  • JavaScript 6.5%
  • HTML 6.1%
  • CSS 5.1%
  • Just 0.9%
Find a file
Philipp Naumann b2c5bb2a4c Initial commit: Rust reimplementation of Claras Tagebuch
Extracted from the rust-port branch of the diary repo (commit 85746b3),
promoted to the repository root.
2026-06-23 20:55:01 +02:00
src Initial commit: Rust reimplementation of Claras Tagebuch 2026-06-23 20:55:01 +02:00
static Initial commit: Rust reimplementation of Claras Tagebuch 2026-06-23 20:55:01 +02:00
templates Initial commit: Rust reimplementation of Claras Tagebuch 2026-06-23 20:55:01 +02:00
.gitignore Initial commit: Rust reimplementation of Claras Tagebuch 2026-06-23 20:55:01 +02:00
Cargo.lock Initial commit: Rust reimplementation of Claras Tagebuch 2026-06-23 20:55:01 +02:00
Cargo.toml Initial commit: Rust reimplementation of Claras Tagebuch 2026-06-23 20:55:01 +02:00
justfile Initial commit: Rust reimplementation of Claras Tagebuch 2026-06-23 20:55:01 +02:00
README.md Initial commit: Rust reimplementation of Claras Tagebuch 2026-06-23 20:55:01 +02:00

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
Mail 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_DSN stays 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. TIMESTAMP columns are read/written as chrono::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's loc=UTC labeling; 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"): redirect always emits 303; the thumbnail Content-Type is the quirky application/jpeg; entry positions are spaced by 10.
  • The Go repository code generator is dropped — the four entities have hand-written sqlx repositories 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.