tauri-plugin-intent 0.1.0

Tauri plugin for handling Android and iOS intents.
Documentation
use serde::de::DeserializeOwned;
use tauri::{
    plugin::{PluginApi, PluginHandle},
    AppHandle, Runtime,
};

use crate::models::*;

#[cfg(target_os = "ios")]
tauri::ios_plugin_binding!(init_plugin_intent);

// initializes the Kotlin or Swift plugin classes
pub fn init<R: Runtime, C: DeserializeOwned>(
    _app: &AppHandle<R>,
    api: PluginApi<R, C>,
) -> crate::Result<Intent<R>> {
    #[cfg(target_os = "android")]
    let handle = api.register_android_plugin("com.plugin.intent", "IntentPlugin")?;
    #[cfg(target_os = "ios")]
    let handle = api.register_ios_plugin(init_plugin_intent)?;
    Ok(Intent(handle))
}

/// Access to the intent APIs.
pub struct Intent<R: Runtime>(PluginHandle<R>);

impl<R: Runtime> Intent<R> {
    pub async fn open_intent(
        &self,
        payload: OpenIntentRequest,
    ) -> crate::Result<OpenIntentResponse> {
        self.0
            .run_mobile_plugin("openIntent", payload)
            .map_err(Into::into)
    }
}