Skip to content

refactor(core): allow custom protocol handler to resolve async #4730

refactor(core): allow custom protocol handler to resolve async

refactor(core): allow custom protocol handler to resolve async #4730

GitHub Actions / empty failed Sep 5, 2023 in 0s

empty

1 error

Details

Results

Message level Amount
Internal compiler error 0
Error 1
Warning 0
Note 0
Help 0

Versions

  • rustc 1.72.0 (5680fa18f 2023-08-23)
  • cargo 1.72.0 (103a7ff2e 2023-08-15)
  • clippy 0.1.72 (5680fa1 2023-08-23)

Annotations

Check failure on line 255 in core/tauri/src/ipc/protocol.rs

See this annotation in the file changed.

@github-actions github-actions / empty

this let-binding has unit value

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 +         );
    |