Profile B: Rust Desktop & CLI App (Tauri v2 + Local Store)
Use this profile for native Windows/macOS/Linux utilities, developer tools, system-tray apps, and paired Rust CLIs.
Recommended Stack Additions
- Desktop Shell (
desktop-tauri/src-tauri):tauriv2 (features = ["tray-icon", "image-png", "image-ico"]),tauri-plugin-single-instance,tauri-build. - CLI Companion (
crates/<prefix>-cli): Shares the exact sameL4 engine+L5 integrationscrates and supports--jsonoutput for scripting and smoke testing. - Local Persistence (
crates/<prefix>-store):SessionStoretrait withJsonFileStore(atomic write-to-.tmp+fs::renamefor settings/history/audit) or embedded SQLite, plusMemoryStorefor isolated unit tests.- Inject
app.path().app_data_dir()from the Tauri shell soL3 storenever importstauri.
- Network / OS Adapters (
crates/<prefix>-integrations):reqwestwithdefault-features = false, features = ["native-tls", "socks"]avoids requiringnasm/aws-lc-rsC toolchains on Windows while using the OS certificate store.- On Windows, set
.creation_flags(0x0800_0000)(CREATE_NO_WINDOW) on everytokio::process::Commandso background CLI invocations never flash console windows. - Enforce explicit timeouts and byte caps on every subprocess output and HTTP body.
Tauri v2 Specific Practices
- Isolate
#[tauri::command]macro expansions fromclippy::unreachable: Tauri's#[tauri::command]macro generates hidden IPC dispatch code that triggersclippy::unreachable. Keep all workspace lints strict globally and isolate IPC handlers in a tiny wrapper module:
Similarly, keepmod ipc { #![allow(clippy::unreachable)] // thin wrappers delegating straight to Engine::execute }#[allow(...)]fortauri::generate_context!()strictly on thepub fn run()shell entrypoint. - Prevent white flash on startup: Set
"backgroundColor"intauri.conf.jsonto match your dark canvas surface (e.g.,"#0F0F0F"). - Embed tray icons at compile time: Use
include_bytes!("../icons/tray.png")+tauri::image::Image::from_bytes(...)so portable single-.exebuilds never break from missing relative paths. - Update tray menu items in place: Hold
MenuItem<Wry>handles and call.set_enabled(...)/tray.set_tooltip(...)instead of tearing down the tray menu on every state tick. - Single-instance & close-to-tray: Focus the existing main window on second launch; intercept
WindowEvent::CloseRequestedto hide the window whenclose_to_trayis enabled and exit cleanly whenQuitis clicked from the tray menu. - Strict CSP: Lock
app.security.cspintauri.conf.jsonto'self'and Tauri IPC origins (ipc: http://ipc.localhost https://ipc.localhost).