rust-for-tauri
Just enough Rust to write Tauri command handlers — types, ownership, borrowing, error handling with Result/anyhow, async with tokio, and JSON serialization with serde. Use when a Tauri developer needs Rust guidance without learning the full language.
| Model | Source |
|---|---|
| sonnet | pack: desktop |
Full Reference
┏━ 🔧 rust-for-tauri ━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Survival Rust for Tauri command handler authors ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
rust-for-tauri
Section titled “rust-for-tauri”The 80/20 Rust you need to write Tauri backends. Not a full Rust course — just the patterns that appear in every src-tauri/ directory.
Quick Reference
Section titled “Quick Reference”| Item | Value |
|---|---|
| Rust edition | 2021 (default in Tauri projects) |
| Key crates | serde, serde_json, tokio, anyhow, tauri |
| Entry point | src-tauri/src/main.rs |
| Command macro | #[tauri::command] |
| Invoke from JS | import { invoke } from '@tauri-apps/api/tauri' |
The Tauri Command Shape
Section titled “The Tauri Command Shape”#[tauri::command]async fn my_command(name: String) -> Result<String, String> { Ok(format!("Hello, {}!", name))}Every command returns Result<T, String> (or Result<T, E> where E implements Serialize). The Ok value reaches JS as the resolved value; Err rejects the promise.
Reference Index
Section titled “Reference Index”| I want to… | File |
|---|---|
| Understand types, ownership, and borrowing fast | reference/survival-rust.md |
| Handle errors with Result and anyhow | reference/error-handling.md |
| Write async commands with tokio | reference/async-rust.md |
| Serialize/deserialize structs to/from JSON | reference/serde.md |
Usage: Read the reference file matching your current task. Each file is self-contained with Tauri-specific code examples and inline gotchas.