Skip to content

Commit ff01c57

Browse files
Fixing format issues on rust code
1 parent f64ea81 commit ff01c57

4 files changed

Lines changed: 28 additions & 28 deletions

File tree

src-tauri/src/desktop.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,16 @@ pub fn setup_system_tray_icon(app: &mut App) {
4444
match button {
4545
MouseButton::Left => {
4646
dbg!("system tray received a right click");
47-
let window =
48-
tray_icon.app_handle().get_webview_window("main").unwrap();
47+
let window = tray_icon.app_handle().get_webview_window("main").unwrap();
4948
let display = match window.is_visible() {
5049
Ok(visible) => {
5150
if visible {
5251
window.hide()
5352
} else {
5453
window.show()
5554
}
56-
},
57-
Err(_) => window.show()
55+
}
56+
Err(_) => window.show(),
5857
};
5958
//window.hide().unwrap();
6059
display.unwrap();
@@ -87,18 +86,15 @@ pub fn setup_system_tray_icon(app: &mut App) {
8786

8887
#[cfg(desktop)]
8988
#[tauri::command]
90-
pub fn set_frontend_complete(
91-
app: AppHandle,
92-
) -> Result<(), ()> {
93-
89+
pub fn set_frontend_complete(app: AppHandle) -> Result<(), ()> {
9490
let splash_window;
9591
if app.get_webview_window("splashscreen").is_some() {
9692
splash_window = app.get_webview_window("splashscreen").unwrap();
9793
} else {
9894
return Err(());
9995
}
10096
let main_window = app.get_webview_window("main").unwrap();
101-
97+
10298
//main_window.set_enabled(true).unwrap();
10399
main_window.show().unwrap();
104100

src-tauri/src/http.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::thread;
2-
use tiny_http::{Request, Response, ResponseBox, Header};
3-
2+
use tiny_http::{Header, Request, Response, ResponseBox};
43

54
#[tauri::command]
65
pub fn start_http_server(otp_code: String, backup_data: String) {
@@ -19,10 +18,10 @@ impl HttpServer {
1918
fn new() -> Self {
2019
Self {
2120
otp_code: String::new(),
22-
json_data: String::new()
21+
json_data: String::new(),
2322
}
2423
}
25-
24+
2625
fn start_server(&mut self, otp_code: String, backup_data: String) {
2726
self.otp_code = otp_code;
2827
self.json_data = backup_data;
@@ -39,14 +38,14 @@ impl HttpServer {
3938
continue;
4039
}
4140
req
42-
},
41+
}
4342
Err(_err) => {
4443
dbg!("Couldn't receive the request.");
45-
return ;
44+
return;
4645
}
4746
};
4847
let response = self.handle_incoming_request(&request);
49-
48+
5049
if let Some(response) = response {
5150
let _ = request.respond(response);
5251
continue;
@@ -64,7 +63,7 @@ impl HttpServer {
6463
dbg!("Returned the response");
6564
return response;
6665
}
67-
66+
6867
if request.url() == "/handshake" {
6968
dbg!("Received a POST method on /handshake url");
7069
return self.handshake(request);
@@ -82,18 +81,24 @@ impl HttpServer {
8281
.headers()
8382
.iter()
8483
.find_map(|header| {
85-
dbg!("Header {:?} with value {:?}", header.field.as_str(), header.value.as_str());
84+
dbg!(
85+
"Header {:?} with value {:?}",
86+
header.field.as_str(),
87+
header.value.as_str()
88+
);
8689
if header.field.as_str() == "X-SIGNED-TOKEN" {
8790
dbg!("Returned the header {:?}", header.value.as_str());
8891
return Some(header.value.as_str());
8992
}
9093
None
91-
}).unwrap();
94+
})
95+
.unwrap();
9296
dbg!("Valor to token: {:?}", &otp_token);
9397

9498
if otp_token.is_empty() {
9599
let response = Response::from_string("Empty token".to_string())
96-
.with_status_code(500).boxed();
100+
.with_status_code(500)
101+
.boxed();
97102
return Some(response);
98103
}
99104
self.response_with_cors_headers(self.json_data.as_str())
@@ -109,4 +114,4 @@ impl HttpServer {
109114
.boxed();
110115
Some(response)
111116
}
112-
}
117+
}

src-tauri/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
use serde::{Deserialize, Serialize};
22
use std::env;
33

4-
54
#[cfg(desktop)]
65
mod desktop;
76

87
#[cfg(not(desktop))]
98
mod android;
109

11-
mod mdns;
1210
mod http;
11+
mod mdns;
1312

1413
#[cfg_attr(mobile, tauri::mobile_entry_point)]
1514
pub fn run() {
@@ -40,7 +39,6 @@ pub fn run() {
4039
.expect("error while running tauri application");
4140
}
4241

43-
4442
#[derive(Deserialize, Serialize)]
4543
struct Secrets {
4644
project: String,

src-tauri/src/mdns.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,15 @@ pub fn broadcast_service() {
7676
ip,
7777
port,
7878
&properties[..],
79-
).unwrap();
79+
)
80+
.unwrap();
8081
// Register with the daemon, which publishes the service.
81-
mdns.register(my_service).expect("Failed to register our service");
82+
mdns.register(my_service)
83+
.expect("Failed to register our service");
8284

8385
dbg!(format!("Broadcasting services of type {:?}", service_type));
8486

85-
8687
// Gracefully shutdown the daemon
8788
std::thread::sleep(std::time::Duration::from_secs(1));
8889
mdns.shutdown().unwrap();
89-
}
90+
}

0 commit comments

Comments
 (0)