creddy/src-tauri/src/main.rs

41 lines
1.0 KiB
Rust
Raw Normal View History

2022-08-14 20:27:41 +00:00
#![cfg_attr(
2022-12-14 05:50:34 +00:00
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
2022-08-14 20:27:41 +00:00
)]
use tauri::Manager;
mod config;
2022-11-29 00:16:33 +00:00
mod errors;
2022-12-04 05:47:09 +00:00
mod clientinfo;
2022-11-29 00:16:33 +00:00
mod ipc;
mod state;
mod server;
2022-08-14 20:27:41 +00:00
use state::AppState;
2022-08-14 20:27:41 +00:00
fn main() {
2022-12-14 05:50:34 +00:00
let initial_state = match state::AppState::new() {
Ok(state) => state,
Err(e) => {eprintln!("{}", e); return;}
};
tauri::Builder::default()
.manage(initial_state)
.invoke_handler(tauri::generate_handler![
ipc::unlock,
ipc::respond,
ipc::get_session_status,
ipc::save_credentials,
])
.setup(|app| {
let state = app.state::<AppState>();
let config = state.config.read().unwrap();
let addr = std::net::SocketAddrV4::new(config.listen_addr, config.listen_port);
2022-12-14 05:50:34 +00:00
tauri::async_runtime::spawn(server::serve(addr, app.handle()));
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
2022-11-29 00:16:33 +00:00
}