Tauri command

From HopeArtOrg/hope-re · View interactive version

Tauri command is an AI agent skill from the GitHub repository HopeArtOrg/hope-re. Create a new Rust Tauri v2 command following Hope:RE error handling and module conventions

How to use this skill

Skill file

Tauri Command Pattern

When creating a new Tauri command in Hope:RE, follow these conventions:

Command Function

#[tauri::command]
pub async fn my_command(
    app: tauri::AppHandle,
    input_param: String,
) -> Result<MyOutput, String> {
    let result = some_operation(&input_param)
        .map_err(|e| format!("Failed to do operation: {}", e))?;

    let _ = app.emit("my-event", &result);

    log::info!("Operation completed successfully");
    Ok(result)
}

Struct Definitions

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct MyOutput {
    pub field: String,
    pub optional_field: Option<u32>,
}

Registration in `lib.rs`

Add the command to the tauri::Builder invoke handler:

.invoke_handler(tauri::generate_handler![
    commands::my_command,
])

Rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.