refactor(core): allow custom protocol handler to resolve async #772
Annotations
7 errors and 1 warning
function `format_result` is never used:
core/tauri/src/ipc/format_callback.rs#L110
error: function `format_result` is never used
--> core/tauri/src/ipc/format_callback.rs:110:8
|
110 | pub fn format_result<T: Serialize, E: Serialize>(
| ^^^^^^^^^^^^^
|
function `format` is never used:
core/tauri/src/ipc/format_callback.rs#L86
error: function `format` is never used
--> core/tauri/src/ipc/format_callback.rs:86:8
|
86 | pub fn format<T: Serialize>(function_name: CallbackFn, arg: &T) -> crate::api::Result<String> {
| ^^^^^^
|
function `serialize_js_with` is never used:
core/tauri/src/ipc/format_callback.rs#L43
error: function `serialize_js_with` is never used
--> core/tauri/src/ipc/format_callback.rs:43:4
|
43 | fn serialize_js_with<T: Serialize, F: FnOnce(&str) -> String>(
| ^^^^^^^^^^^^^^^^^
|
constant `MIN_JSON_PARSE_LEN` is never used:
core/tauri/src/ipc/format_callback.rs#L23
error: constant `MIN_JSON_PARSE_LEN` is never used
--> core/tauri/src/ipc/format_callback.rs:23:7
|
23 | const MIN_JSON_PARSE_LEN: usize = 10_240;
| ^^^^^^^^^^^^^^^^^^
|
constant `MAX_JSON_STR_LEN` is never used:
core/tauri/src/ipc/format_callback.rs#L18
error: constant `MAX_JSON_STR_LEN` is never used
--> core/tauri/src/ipc/format_callback.rs:18:7
|
18 | const MAX_JSON_STR_LEN: usize = usize::pow(2, 30) - 2;
| ^^^^^^^^^^^^^^^^
|
= note: `-D dead-code` implied by `-D warnings`
|
this let-binding has unit value:
core/tauri/src/ipc/protocol.rs#L196
error: this let-binding has unit value
--> core/tauri/src/ipc/protocol.rs:196:9
|
196 | / let _ = window.on_message(
197 | | InvokeRequest {
198 | | cmd: message.cmd,
199 | | callback: message.callback,
... |
254 | | }),
255 | | );
| |__________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
= note: `-D clippy::let-unit-value` implied by `-D warnings`
help: omit the `let` binding
|
196 ~ window.on_message(
197 + InvokeRequest {
198 + cmd: message.cmd,
199 + callback: message.callback,
200 + error: message.error,
201 + body: message.payload.into(),
202 + headers: message.options.map(|o| o.headers.0).unwrap_or_default(),
203 + },
204 + Box::new(move |window, cmd, response, callback, error| {
205 + use crate::ipc::{
206 + format_callback::{
207 + format as format_callback, format_result as format_callback_result,
208 + },
209 + Channel,
210 + };
211 + use serde_json::Value as JsonValue;
212 +
213 + // the channel data command is the only command that uses a custom protocol on Linux
214 + if window.manager.invoke_responder().is_none()
215 + && cmd != crate::ipc::channel::FETCH_CHANNEL_DATA_COMMAND
216 + {
217 + fn responder_eval<R: Runtime>(
218 + window: &crate::Window<R>,
219 + js: crate::api::Result<String>,
220 + error: CallbackFn,
221 + ) {
222 + let eval_js = match js {
223 + Ok(js) => js,
224 + Err(e) => format_callback(error, &e.to_string())
225 + .expect("unable to serialize response error string to json"),
226 + };
227 +
228 + let _ = window.eval(&eval_js);
229 + }
230 +
231 + match &response {
232 + InvokeResponse::Ok(InvokeBody::Json(v)) => {
233 + if matches!(v, JsonValue::Object(_) | JsonValue::Array(_)) {
234 + let _ = Channel::from_ipc(window.clone(), callback).send(v);
235 + } else {
236 + responder_eval(
237 + &window,
238 + format_callback_result(Result::<_, ()>::Ok(v), callback, error),
239 + error,
240 + )
241 + }
242 + }
243 + InvokeResponse::Ok(InvokeBody::Raw(v)) => {
244 + let _ =
245 + Channel::from_ipc(window.clone(), callback).send(InvokeBody::Raw(v.clone()));
246 + }
247 + InvokeResponse::Err(e) => responder_eval(
248 + &window,
249 + format_callback_result(Result::<(), _>::Err(&e.0), callback, error),
250 + error,
251 + ),
252 + }
253 + }
254 + }),
255 + );
|
|
this let-binding has unit value:
core/tauri/src/ipc/protocol.rs#L196
error: this let-binding has unit value
--> core/tauri/src/ipc/protocol.rs:196:9
|
196 | / let _ = window.on_message(
197 | | InvokeRequest {
198 | | cmd: message.cmd,
199 | | callback: message.callback,
... |
254 | | }),
255 | | );
| |__________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
= note: `-D clippy::let-unit-value` implied by `-D warnings`
help: omit the `let` binding
|
196 ~ window.on_message(
197 + InvokeRequest {
198 + cmd: message.cmd,
199 + callback: message.callback,
200 + error: message.error,
201 + body: message.payload.into(),
202 + headers: message.options.map(|o| o.headers.0).unwrap_or_default(),
203 + },
204 + Box::new(move |window, cmd, response, callback, error| {
205 + use crate::ipc::{
206 + format_callback::{
207 + format as format_callback, format_result as format_callback_result,
208 + },
209 + Channel,
210 + };
211 + use serde_json::Value as JsonValue;
212 +
213 + // the channel data command is the only command that uses a custom protocol on Linux
214 + if window.manager.invoke_responder().is_none()
215 + && cmd != crate::ipc::channel::FETCH_CHANNEL_DATA_COMMAND
216 + {
217 + fn responder_eval<R: Runtime>(
218 + window: &crate::Window<R>,
219 + js: crate::api::Result<String>,
220 + error: CallbackFn,
221 + ) {
222 + let eval_js = match js {
223 + Ok(js) => js,
224 + Err(e) => format_callback(error, &e.to_string())
225 + .expect("unable to serialize response error string to json"),
226 + };
227 +
228 + let _ = window.eval(&eval_js);
229 + }
230 +
231 + match &response {
232 + InvokeResponse::Ok(InvokeBody::Json(v)) => {
233 + if matches!(v, JsonValue::Object(_) | JsonValue::Array(_)) {
234 + let _ = Channel::from_ipc(window.clone(), callback).send(v);
235 + } else {
236 + responder_eval(
237 + &window,
238 + format_callback_result(Result::<_, ()>::Ok(v), callback, error),
239 + error,
240 + )
241 + }
242 + }
243 + InvokeResponse::Ok(InvokeBody::Raw(v)) => {
244 + let _ =
245 + Channel::from_ipc(window.clone(), callback).send(InvokeBody::Raw(v.clone()));
246 + }
247 + InvokeResponse::Err(e) => responder_eval(
248 + &window,
249 + format_callback_result(Result::<(), _>::Err(&e.0), callback, error),
250 + error,
251 + ),
252 + }
253 + }
254 + }),
255 + );
|
|
covector
The following actions uses node12 which is deprecated and will be forced to run on node16: actions/checkout@v2. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
|