What problem does it solve?
It prevents broken or inconsistent SQLite/Rust database layer changes by documenting the exact Tauri + rusqlite connection lifecycle, SQL command primitives, parameter binding rules, and where new logic should live.
Core Features & Use Cases
- Connection lifecycle & safety model: how the single global SQLite connection is opened, guarded by a Mutex, switched between DB files, and closed.
- SQL primitive contract: how the renderer-side db-shim calls the five generic Rust commands (db_batch, db_run, db_run_changes, db_get, db_all) and what shapes return.
- Correct SQL binding & transactions: positional parameter binding via
? placeholders, supported JSON-to-SQL coercions, and the recommended transaction pattern using BEGIN IMMEDIATE/COMMIT/ROLLBACK.
- Guidance on code placement: decision criteria for adding logic to
src/api/ versus introducing new #[tauri::command] functions in Rust.
- Type marshalling expectations: how SQL row values are marshalled into JSON types, including defensive handling for BLOB columns.
Quick Start
When modifying src-tauri/src/db.rs, ask the AI to explain how to implement your new SQL helper consistently with the existing db_* primitives, including parameter binding, transactions, and whether the change should go in src/api/ or as a Rust command.