creddy/src-tauri/src/main.rs

44 lines
1.1 KiB
Rust
Raw Normal View History

2022-08-14 20:27:41 +00:00
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use std::str::FromStr;
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
mod storage;
fn main() {
2022-12-04 05:47:09 +00:00
let initial_state = match state::AppState::new() {
2022-12-03 06:59:13 +00:00
Ok(state) => state,
Err(e) => {eprintln!("{}", e); return;}
};
2022-11-29 00:16:33 +00:00
2022-08-14 20:27:41 +00:00
tauri::Builder::default()
2022-11-29 00:16:33 +00:00
.manage(initial_state)
2022-12-14 00:50:44 +00:00
.invoke_handler(tauri::generate_handler![
ipc::unlock,
ipc::respond,
ipc::get_session_status,
])
2022-08-14 20:27:41 +00:00
.setup(|app| {
let addr = std::net::SocketAddrV4::from_str("127.0.0.1:12345").unwrap();
2022-11-29 00:16:33 +00:00
tauri::async_runtime::spawn(server::serve(addr, app.handle()));
2022-08-14 20:27:41 +00:00
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
// let addr = std::net::SocketAddrV4::from_str("127.0.0.1:12345").unwrap();
// let rt = Runtime::new().unwrap();
// rt.block_on(http::serve(addr)).unwrap();
// let creds = std::fs::read_to_string("credentials.json").unwrap();
// storage::save(&creds, "correct horse battery staple");
2022-11-29 00:16:33 +00:00
}