tauri_ipclisted
Install: claude install-skill feralbureau/luminy
# tauri_ipc
Tauri's IPC (Inter-Process Communication) bridge connects the Rust backend to the JavaScript frontend. All data crossing this boundary is serialized to/from JSON. Understanding this constraint is the key to building reliable Tauri IPC correctly.
## The Mental Model
```
Frontend (TypeScript) IPC Bridge Backend (Rust)
───────────────────── ────────── ──────────────
invoke('command', args) → JSON serialize → #[tauri::command] fn
← JSON serialize ← Result<T, E>
listen('event', handler) ← JSON serialize ← app_handle.emit_all()
```
Every value that crosses the bridge must be serializable to JSON. This means:
- Rust types must implement `serde::Serialize` (for return values) and `serde::Deserialize` (for arguments).
- Complex types like `HashMap`, `Vec`, enums, and nested structs all work as long as they derive these traits.
- Types that DON'T serialize: raw pointers, `Arc`, `Mutex` (the value inside might), file handles, etc.
## Defining Rust Commands
```rust
// src-tauri/src/commands/orders.rs
use serde::{Deserialize, Serialize};
use tauri::State;
use crate::domain::OrderService;
use crate::errors::AppError;
// Input: must implement Deserialize
#[derive(Debug, Deserialize)]
pub struct CreateOrderArgs {
pub user_id: i64,
pub product_ids: Vec<i64>,
pub coupon_code: Option<String>,
}
// Output: must implement Serialize
#[derive(Debug, Serialize)]
pub struct CreateOrderResult {