/
githubmirror
/
tauri
Обзор
Документация
Войти
/
githubmirror
/
tauri
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
examples/api/src-tauri/tauri-plugin-sample/src/mobile.rs
41 строка
1 KB
Amr Bashir
chore: update license headers 2024 (#9043)
01 мар 2024, 14:29
Не верифицирован
01 мар 2024, 14:29
4b75834
Код
Авторство
О чём код?
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT use serde::de::DeserializeOwned; use tauri::{ plugin::{PluginApi, PluginHandle}, AppHandle, Runtime, }; use crate::models::*; #[cfg(target_os = "android")] const PLUGIN_IDENTIFIER: &str = "com.plugin.sample"; #[cfg(target_os = "ios")] tauri::ios_plugin_binding!(init_plugin_sample); // initializes the Kotlin or Swift plugin classes pub fn init<R: Runtime, C: DeserializeOwned>( _app: &AppHandle<R>, api: PluginApi<R, C>, ) -> crate::Result<Sample<R>> { #[cfg(target_os = "android")] let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "ExamplePlugin")?; #[cfg(target_os = "ios")] let handle = api.register_ios_plugin(init_plugin_sample)?; Ok(Sample(handle)) } /// A helper class to access the sample APIs. pub struct Sample<R: Runtime>(PluginHandle<R>); impl<R: Runtime> Sample<R> { pub fn ping(&self, payload: PingRequest) -> crate::Result<PingResponse> { self .0 .run_mobile_plugin("ping", payload) .map_err(Into::into) } }