You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
844 B

mod device;
mod ble;
mod device_repo;
use crate::{ble::scan_devices, device::Device, device_repo::{repo_from_devices, try_from_file, Repo}};
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
#[tauri::command]
async fn read_repo() -> Vec<Device> {
vec![]
}
#[tauri::command]
async fn scan() -> Repo {
match try_from_file() {
Ok(repo) => repo,
Err(_) => {
let devices = (scan_devices(20).await).unwrap_or_default();
repo_from_devices(devices)
}
}
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![read_repo, scan])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}