@@ -136,13 +136,13 @@ pub async fn config_all(state: State<'_, AppState>, _args: Args) -> Result<Value
136136
137137#[ tauri:: command]
138138pub async fn config_get ( state : State < ' _ , AppState > , args : Args ) -> Result < Value , StorageError > {
139- let key = args
140- . first ( )
141- . and_then ( Value :: as_str)
142- . ok_or_else ( || StorageError :: InvalidConfigValue {
143- key : "<arg0>" . into ( ) ,
144- reason : "config_get requires a string key as the first argument" . into ( ) ,
145- } ) ?;
139+ let key =
140+ args . first ( )
141+ . and_then ( Value :: as_str)
142+ . ok_or_else ( || StorageError :: InvalidConfigValue {
143+ key : "<arg0>" . into ( ) ,
144+ reason : "config_get requires a string key as the first argument" . into ( ) ,
145+ } ) ?;
146146 let cfg = state. config . lock ( ) . expect ( "config mutex poisoned" ) ;
147147 Ok ( cfg. get_key ( key) . unwrap_or ( Value :: Null ) )
148148}
@@ -280,11 +280,7 @@ fn apply_launch_at_login(app: &AppHandle<Wry>, enabled: bool) -> Result<(), Stor
280280///
281281/// Pinned to `Wry` because the HTTP API server is itself pinned to
282282/// `Wry` (see the comment in `http_api.rs`).
283- fn apply_side_effects (
284- app : & AppHandle < Wry > ,
285- state : & AppState ,
286- touched_keys : & [ & str ] ,
287- ) {
283+ fn apply_side_effects ( app : & AppHandle < Wry > , state : & AppState , touched_keys : & [ & str ] ) {
288284 let touches_http_api = touched_keys
289285 . iter ( )
290286 . any ( |k| * k == "http_api_on" || * k == "http_api_only_local" ) ;
@@ -411,11 +407,7 @@ pub async fn get_content_of_list(
411407 cfg. remove_duplicate_records
412408 } ;
413409
414- let content = hosts_apply:: aggregate_selected_content (
415- & list,
416- & state. paths ,
417- remove_duplicate,
418- ) ?;
410+ let content = hosts_apply:: aggregate_selected_content ( & list, & state. paths , remove_duplicate) ?;
419411 Ok ( json ! ( content) )
420412}
421413
@@ -807,9 +799,8 @@ pub async fn get_apply_history(
807799) -> Result < Value , StorageError > {
808800 let path = state. paths . histories_dir . join ( "system-hosts.json" ) ;
809801 let items = hosts_apply:: history:: load ( & path) ?;
810- let value = serde_json:: to_value ( items) . map_err ( |e| {
811- StorageError :: serialize ( path. display ( ) . to_string ( ) , e)
812- } ) ?;
802+ let value = serde_json:: to_value ( items)
803+ . map_err ( |e| StorageError :: serialize ( path. display ( ) . to_string ( ) , e) ) ?;
813804 Ok ( value)
814805}
815806
@@ -833,9 +824,8 @@ pub async fn cmd_get_history_list(
833824) -> Result < Value , StorageError > {
834825 let path = state. paths . histories_dir . join ( "cmd-after-apply.json" ) ;
835826 let items = hosts_apply:: cmd_runner:: load ( & path) ?;
836- let value = serde_json:: to_value ( items) . map_err ( |e| {
837- StorageError :: serialize ( path. display ( ) . to_string ( ) , e)
838- } ) ?;
827+ let value = serde_json:: to_value ( items)
828+ . map_err ( |e| StorageError :: serialize ( path. display ( ) . to_string ( ) , e) ) ?;
839829 Ok ( value)
840830}
841831
@@ -882,10 +872,7 @@ pub async fn find_set_window_title<R: Runtime + 'static>(
882872}
883873
884874#[ tauri:: command]
885- pub async fn find_by (
886- state : State < ' _ , AppState > ,
887- args : Args ,
888- ) -> Result < Value , String > {
875+ pub async fn find_by ( state : State < ' _ , AppState > , args : Args ) -> Result < Value , String > {
889876 let keyword = args
890877 . first ( )
891878 . and_then ( Value :: as_str)
@@ -901,27 +888,20 @@ pub async fn find_by(
901888}
902889
903890#[ tauri:: command]
904- pub async fn find_replace_one (
905- state : State < ' _ , AppState > ,
906- args : Args ,
907- ) -> Result < Value , String > {
891+ pub async fn find_replace_one ( state : State < ' _ , AppState > , args : Args ) -> Result < Value , String > {
908892 let request = args
909893 . into_iter ( )
910894 . next ( )
911895 . ok_or_else ( || "find_replace_one: args[0] must be a request object" . to_string ( ) )
912896 . and_then ( |v| {
913- serde_json:: from_value ( v)
914- . map_err ( |e| format ! ( "find_replace_one: invalid request: {e}" ) )
897+ serde_json:: from_value ( v) . map_err ( |e| format ! ( "find_replace_one: invalid request: {e}" ) )
915898 } ) ?;
916899 let replaced = find:: replace_one_in_manifest ( state. inner ( ) , request) ?;
917900 Ok ( json ! ( replaced) )
918901}
919902
920903#[ tauri:: command]
921- pub async fn find_replace_all (
922- state : State < ' _ , AppState > ,
923- args : Args ,
924- ) -> Result < Value , String > {
904+ pub async fn find_replace_all ( state : State < ' _ , AppState > , args : Args ) -> Result < Value , String > {
925905 let keyword = args
926906 . first ( )
927907 . and_then ( Value :: as_str)
@@ -1079,9 +1059,7 @@ pub async fn open_url(args: Args) -> Value {
10791059 return Value :: Null ;
10801060 } ;
10811061 let lower = url. to_ascii_lowercase ( ) ;
1082- if lower. starts_with ( "http://" )
1083- || lower. starts_with ( "https://" )
1084- || lower. starts_with ( "mailto:" )
1062+ if lower. starts_with ( "http://" ) || lower. starts_with ( "https://" ) || lower. starts_with ( "mailto:" )
10851063 {
10861064 let _ = open:: that ( url) ;
10871065 } else {
@@ -1234,10 +1212,7 @@ pub async fn import_data<R: Runtime>(
12341212}
12351213
12361214#[ tauri:: command]
1237- pub async fn import_data_from_url (
1238- state : State < ' _ , AppState > ,
1239- args : Args ,
1240- ) -> Result < Value , String > {
1215+ pub async fn import_data_from_url ( state : State < ' _ , AppState > , args : Args ) -> Result < Value , String > {
12411216 let url = arg_str ( & args, 0 , "url" ) . map_err ( |e| format ! ( "{e:?}" ) ) ?;
12421217
12431218 // Build the HTTP client outside of any lock so the proxy snapshot
@@ -1357,7 +1332,13 @@ pub async fn download_update<R: Runtime>(
13571332 . download_and_install (
13581333 move |downloaded, total| {
13591334 let percent = total
1360- . map ( |t| if t > 0 { ( downloaded as f64 / t as f64 ) * 100.0 } else { 0.0 } )
1335+ . map ( |t| {
1336+ if t > 0 {
1337+ ( downloaded as f64 / t as f64 ) * 100.0
1338+ } else {
1339+ 0.0
1340+ }
1341+ } )
13611342 . unwrap_or ( 0.0 ) ;
13621343 let _ = app_for_progress. emit (
13631344 "update_download_progress" ,
0 commit comments