Skip to main content

handler

Macro handler 

Source
handler!() { /* proc-macro */ }
Expand description

Re-export the handler!() macro from conduit-derive.

Resolves a #[command] function name to its conduit handler struct for registration:

tauri_plugin_conduit::init()
    .handler("greet", handler!(greet))
    .build()

Resolve a #[command] function name to its generated handler struct.

Expands handler!(foo) to the hidden unit struct __conduit_handler_foo that #[command] generates alongside the original function. The struct implements [conduit_core::ConduitHandler] and is intended for registration with PluginBuilder::handler.

§Requirements

The target function must have #[command] applied. If #[command] is missing, the compiler will report “cannot find value __conduit_handler_foo in this scope”.

§Example

use tauri_conduit::{command, handler};

#[command]
fn greet(name: String) -> String {
    format!("Hello, {name}!")
}

// Register with the plugin builder:
tauri_plugin_conduit::init()
    .handler("greet", handler!(greet))
    .build()