Menghubungkan kotlin dengan rust
This commit is contained in:
1 parent
47c9deb82b
commit
9e30bf0a16
6 files changed
+81
-55
No files matched your search
+20
-17
@@ -1,6 +1,6 @@
|
||||
use tauri::{
|
||||
plugin::{Builder, TauriPlugin},
|
||||
Manager, Runtime,
|
||||
plugin::{Builder, TauriPlugin},
|
||||
Manager, Runtime,
|
||||
};
|
||||
|
||||
pub use models::*;
|
||||
@@ -23,26 +23,29 @@ use mobile::Bluclas;
|
||||
|
||||
/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the bluclas APIs.
|
||||
pub trait BluclasExt<R: Runtime> {
|
||||
fn bluclas(&self) -> &Bluclas<R>;
|
||||
fn bluclas(&self) -> &Bluclas<R>;
|
||||
}
|
||||
|
||||
impl<R: Runtime, T: Manager<R>> crate::BluclasExt<R> for T {
|
||||
fn bluclas(&self) -> &Bluclas<R> {
|
||||
self.state::<Bluclas<R>>().inner()
|
||||
}
|
||||
fn bluclas(&self) -> &Bluclas<R> {
|
||||
self.state::<Bluclas<R>>().inner()
|
||||
}
|
||||
}
|
||||
|
||||
/// Initializes the plugin.
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::new("bluclas")
|
||||
.invoke_handler(tauri::generate_handler![commands::ping])
|
||||
.setup(|app, api| {
|
||||
#[cfg(mobile)]
|
||||
let bluclas = mobile::init(app, api)?;
|
||||
#[cfg(desktop)]
|
||||
let bluclas = desktop::init(app, api)?;
|
||||
app.manage(bluclas);
|
||||
Ok(())
|
||||
})
|
||||
.build()
|
||||
Builder::new("bluclas")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
commands::daftar_perangkat,
|
||||
commands::kirim
|
||||
])
|
||||
.setup(|app, api| {
|
||||
#[cfg(mobile)]
|
||||
let bluclas = mobile::init(app, api)?;
|
||||
#[cfg(desktop)]
|
||||
let bluclas = desktop::init(app, api)?;
|
||||
app.manage(bluclas);
|
||||
Ok(())
|
||||
})
|
||||
.build()
|
||||
}
|
||||
Reference in new issue
Block a user