-
Notifications
You must be signed in to change notification settings - Fork 427
Expand file tree
/
Copy pathsettings.rs
More file actions
43 lines (37 loc) · 1.12 KB
/
settings.rs
File metadata and controls
43 lines (37 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use crate::api::Result;
use theseus::prelude::*;
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
tauri::plugin::Builder::new("settings")
.invoke_handler(tauri::generate_handler![
settings_get,
settings_set,
cancel_directory_change,
ensure_default_options_file
])
.build()
}
// Get full settings
// invoke('plugin:settings|settings_get')
#[tauri::command]
pub async fn settings_get() -> Result<Settings> {
let res = settings::get().await?;
Ok(res)
}
// Set full settings
// invoke('plugin:settings|settings_set', settings)
#[tauri::command]
pub async fn settings_set(settings: Settings) -> Result<()> {
settings::set(settings).await?;
Ok(())
}
#[tauri::command]
pub async fn cancel_directory_change() -> Result<()> {
let state = State::get().await?;
let identifier = &state.app_identifier;
settings::cancel_directory_change(identifier).await?;
Ok(())
}
#[tauri::command]
pub async fn ensure_default_options_file() -> Result<std::path::PathBuf> {
Ok(theseus::settings::ensure_default_options_file().await?)
}