pub fn init() -> PluginBuilderExpand description
Create a new conduit plugin builder.
This is the main entry point for using the conduit Tauri plugin:
ⓘ
use tauri_conduit::command;
#[command]
fn greet(name: String) -> String {
format!("Hello, {name}!")
}
#[command]
async fn fetch_data(url: String) -> Result<Vec<u8>, String> {
reqwest::get(&url).await.map_err(|e| e.to_string())?
.bytes().await.map(|b| b.to_vec()).map_err(|e| e.to_string())
}
tauri::Builder::default()
.plugin(
tauri_plugin_conduit::init()
.handler("greet", handler!(greet))
.handler("fetch_data", handler!(fetch_data))
.channel("telemetry")
.build()
)
.run(tauri::generate_context!())
.unwrap();