Skip to content

Commit 65a2b59

Browse files
committed
fmt
1 parent 0a4e6a7 commit 65a2b59

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

src/lib.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,14 @@ if len(signature({}).parameters) != {}:
8585
"#,
8686
&payload.python_function_call, num_args
8787
);
88-
self.runner().run(&py_analyze_sig).await.unwrap_or_else(|_| {
89-
panic!("Number of args doesn't match signature of {}.", payload.python_function_call)
88+
self.runner()
89+
.run(&py_analyze_sig)
90+
.await
91+
.unwrap_or_else(|_| {
92+
panic!(
93+
"Number of args doesn't match signature of {}.",
94+
payload.python_function_call
95+
)
9096
});
9197
};
9298
Ok(StringResponse { value: "Ok".into() })
@@ -107,10 +113,8 @@ if len(signature({}).parameters) != {}:
107113
let value = match py_res.as_str() {
108114
Some(s) => s.to_string(),
109115
None => py_res.to_string(),
110-
};
111-
Ok(StringResponse {
112-
value,
113-
})
116+
};
117+
Ok(StringResponse { value })
114118
}
115119

116120
async fn read_variable(&self, payload: StringRequest) -> crate::Result<StringResponse> {
@@ -217,7 +221,8 @@ pub fn init_and_register<R: Runtime>(python_functions: Vec<&'static str>) -> Tau
217221
register_python_functions(
218222
app,
219223
python_functions.iter().map(|s| s.to_string()).collect(),
220-
).await;
224+
)
225+
.await;
221226
let functions = runner
222227
.read_variable("_tauri_plugin_functions")
223228
.await
@@ -232,10 +237,7 @@ pub fn init_and_register<R: Runtime>(python_functions: Vec<&'static str>) -> Tau
232237
.build()
233238
}
234239

235-
async fn register_python_functions<R: Runtime>(
236-
app: &AppHandle<R>,
237-
python_functions: Vec<String>,
238-
) {
240+
async fn register_python_functions<R: Runtime>(app: &AppHandle<R>, python_functions: Vec<String>) {
239241
for function_name in python_functions {
240242
app.register_function(RegisterRequest {
241243
python_function_call: function_name.clone(),
@@ -247,4 +249,4 @@ async fn register_python_functions<R: Runtime>(
247249
}
248250

249251
#[cfg(test)]
250-
mod tests;
252+
mod tests;

src/tests.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
// git clone https://github.com/marcomq/tauri-plugin-python
55

66
use super::*;
7-
use tauri::{test::{self, MockRuntime}, AppHandle};
7+
use tauri::{
8+
test::{self, MockRuntime},
9+
AppHandle,
10+
};
811

912
/// Creates a mock Tauri app and initializes the PyRunner state.
1013
/// It also runs some initial Python code to set up a variable and a function for testing.
@@ -104,5 +107,8 @@ async fn test_register_after_call_fails() {
104107
};
105108
let result = app.register_function(second_register_payload).await;
106109
assert!(result.is_err());
107-
assert!(result.unwrap_err().to_string().contains("Cannot register after function called"));
108-
}
110+
assert!(result
111+
.unwrap_err()
112+
.to_string()
113+
.contains("Cannot register after function called"));
114+
}

0 commit comments

Comments
 (0)