AI-Studio/runtime/src/main.rs

23 lines
862 B
Rust
Raw Normal View History

2024-03-28 21:26:48 +00:00
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
2024-04-05 20:23:01 +00:00
use keyring::Entry;
2024-03-28 21:26:48 +00:00
fn main() {
tauri::Builder::default()
2024-04-05 20:23:01 +00:00
.invoke_handler(tauri::generate_handler![store_secret, get_secret])
2024-03-28 21:26:48 +00:00
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
2024-04-05 20:23:01 +00:00
#[tauri::command]
fn store_secret(destination: String, user_name: String, secret: String) {
let entry = Entry::new(&format!("mindwork-ai-studio::{}", destination), user_name.as_str()).unwrap();
entry.set_password(secret.as_str()).unwrap();
}
#[tauri::command]
fn get_secret(destination: String, user_name: String) -> String {
let entry = Entry::new(&format!("mindwork-ai-studio::{}", destination), user_name.as_str()).unwrap();
entry.get_password().unwrap()
}