aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src
diff options
context:
space:
mode:
authorGeckoEidechse <gecko.eidechse+git@pm.me>2022-08-25 18:31:00 +0200
committerGeckoEidechse <gecko.eidechse+git@pm.me>2022-08-25 18:31:00 +0200
commitc3b7e07cc371cc2f2e04000c18559dc29910fe7a (patch)
treef8dc3f97f466acf2cbd4b8ee6de6d3d18c35a78c /src-tauri/src
parente365f3cc197f020afa3909490530c55f7beaa51e (diff)
downloadFlightCore-c3b7e07cc371cc2f2e04000c18559dc29910fe7a.tar.gz
FlightCore-c3b7e07cc371cc2f2e04000c18559dc29910fe7a.zip
Switch to spaces
Diffstat (limited to 'src-tauri/src')
-rw-r--r--src-tauri/src/main.rs54
1 files changed, 29 insertions, 25 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 464a5430..430c8111 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -1,9 +1,13 @@
#![cfg_attr(
- all(not(debug_assertions), target_os = "windows"),
- windows_subsystem = "windows"
+ all(not(debug_assertions), target_os = "windows"),
+ windows_subsystem = "windows"
)]
-use std::sync::{Arc, Mutex};
-use std::time::Duration;
+
+use std::{
+ sync::{Arc, Mutex},
+ time::Duration,
+};
+
use tauri::{Manager, State};
use tokio::time::sleep;
@@ -11,34 +15,34 @@ use tokio::time::sleep;
struct Counter(Arc<Mutex<i32>>);
fn main() {
- tauri::Builder::default()
- .setup(|app| {
- let app_handle = app.app_handle();
- tauri::async_runtime::spawn(async move {
- loop {
- sleep(Duration::from_millis(2000)).await;
- println!("sending backend-ping");
- app_handle.emit_all("backend-ping", "ping").unwrap();
- }
- });
-
- Ok(())
- })
- .manage(Counter::default())
- .invoke_handler(tauri::generate_handler![hello_world, add_count])
- .run(tauri::generate_context!())
- .expect("error while running tauri application");
+ tauri::Builder::default()
+ .setup(|app| {
+ let app_handle = app.app_handle();
+ tauri::async_runtime::spawn(async move {
+ loop {
+ sleep(Duration::from_millis(2000)).await;
+ println!("sending backend ping");
+ app_handle.emit_all("backend-ping", "ping").unwrap();
+ }
+ });
+
+ Ok(())
+ })
+ .manage(Counter(Default::default()))
+ .invoke_handler(tauri::generate_handler![hello_world, add_count])
+ .run(tauri::generate_context!())
+ .expect("error while running tauri application");
}
#[tauri::command]
fn hello_world() -> String {
- "Hello World!!!!".to_string()
+ "Hello World!!!".to_string()
}
#[tauri::command]
fn add_count(num: i32, counter: State<'_, Counter>) -> String {
- let mut val = counter.0.lock().unwrap();
- *val += num;
+ let mut val = counter.0.lock().unwrap();
+ *val += num;
- format!("{val}")
+ format!("{val}")
}