|
|
@ -3,7 +3,7 @@
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
|
|
|
|
use serde::{ser::Serializer, Serialize};
|
|
|
|
use serde::{ser::Serializer, Serialize};
|
|
|
|
use tauri::{command, plugin::Plugin, Invoke, Runtime};
|
|
|
|
use tauri::{command, plugin::{Builder as PluginBuilder, TauriPlugin}, Runtime};
|
|
|
|
|
|
|
|
|
|
|
|
use std::{
|
|
|
|
use std::{
|
|
|
|
path::PathBuf,
|
|
|
|
path::PathBuf,
|
|
|
@ -121,25 +121,8 @@ async fn exists(path: PathBuf) -> bool {
|
|
|
|
path.exists()
|
|
|
|
path.exists()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Tauri plugin.
|
|
|
|
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
|
|
|
pub struct FsExtra<R: Runtime> {
|
|
|
|
PluginBuilder::new("fs-extra")
|
|
|
|
invoke_handler: Box<dyn Fn(Invoke<R>) + Send + Sync>,
|
|
|
|
.invoke_handler(tauri::generate_handler![exists, metadata])
|
|
|
|
}
|
|
|
|
.build()
|
|
|
|
|
|
|
|
}
|
|
|
|
impl<R: Runtime> Default for FsExtra<R> {
|
|
|
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
|
|
|
Self {
|
|
|
|
|
|
|
|
invoke_handler: Box::new(tauri::generate_handler![exists, metadata]),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl<R: Runtime> Plugin<R> for FsExtra<R> {
|
|
|
|
|
|
|
|
fn name(&self) -> &'static str {
|
|
|
|
|
|
|
|
"fs-extra"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn extend_api(&mut self, message: Invoke<R>) {
|
|
|
|
|
|
|
|
(self.invoke_handler)(message)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|