Attribute Macro silkenweb_tauri::client_command
source · #[client_command]
Expand description
Add a Tauri command signature to the client.
See the tauri docs for an explanation of commands.
⚠️ It’s the clients responsibility to ensure client and server command signatures match. ⚠️
Commands can fail by returning a Result
, or be infallible by returning
either a plain value or ()
. To specify an infallible command, use
#[silkenweb_tauri::client_command(infallible)]
. To specify a fallible
command that returns a Result
, use
#[silkenweb_tauri::client_command(fallible)]
.
Commands can specify a visibility with pub
or pub(crate)
etc. Commands
must be async
. All argument types must be serde::Serialize
, and all
return types must be serde::Deserialize
.
§Examples
An infallible command with arguments:
#[silkenweb_tauri::client_command(infallible)]
async fn never_fails(arg1: &str, arg2: u64) -> String;
A fallible command:
#[silkenweb_tauri::client_command(fallible)]
async fn might_fail() -> Result<String, String>;
A publicly visible command:
#[silkenweb_tauri::client_command(infallible)]
pub async fn now_you_see_me() -> String;