42 lines
1.1 KiB
Rust
42 lines
1.1 KiB
Rust
use serde::de::DeserializeOwned;
|
|
use tauri::{
|
|
AppHandle, Runtime,
|
|
plugin::{PluginApi, PluginHandle},
|
|
};
|
|
|
|
use crate::models::*;
|
|
|
|
#[cfg(target_os = "ios")]
|
|
tauri::ios_plugin_binding!(init_plugin_bluclas);
|
|
|
|
// initializes the Kotlin or Swift plugin classes
|
|
pub fn init<R: Runtime, C: DeserializeOwned>(
|
|
_app: &AppHandle<R>,
|
|
api: PluginApi<R, C>,
|
|
) -> crate::Result<Bluclas<R>> {
|
|
#[cfg(target_os = "android")]
|
|
let handle = api.register_android_plugin("com.plugin.bluclas", "BluclasPlugin")?;
|
|
#[cfg(target_os = "ios")]
|
|
let handle = api.register_ios_plugin(init_plugin_bluclas)?;
|
|
Ok(Bluclas(handle))
|
|
}
|
|
|
|
/// Access to the bluclas APIs.
|
|
pub struct Bluclas<R: Runtime>(PluginHandle<R>);
|
|
|
|
impl<R: Runtime> Bluclas<R> {
|
|
pub fn daftar_perangkat(&self) -> crate::Result<SBlueclasResponDaftarPerangkat> {
|
|
return self
|
|
.0
|
|
.run_mobile_plugin("daftarPerangkat", ())
|
|
.map_err(Into::into);
|
|
}
|
|
|
|
pub fn kirim(&self, payload: SBlueclasMuatanKirim) -> crate::Result<()> {
|
|
return self
|
|
.0
|
|
.run_mobile_plugin("kirim", payload)
|
|
.map_err(Into::into);
|
|
}
|
|
}
|