(&self, method: &str, params: Value, wait: Duration)
| 672 | |
| 673 | impl InspectorAgentHandle { |
| 674 | async fn query(&self, method: &str, params: Value, wait: Duration) -> Result<Value, String> { |
| 675 | let id = self.next_request_id.fetch_add(1, Ordering::Relaxed); |
| 676 | let request = json!({ |
| 677 | "id": id, |
| 678 | "method": method, |
| 679 | "params": params, |
| 680 | }); |
| 681 | let (response_tx, response_rx) = oneshot::channel(); |
| 682 | self.pending.lock().await.insert(id, response_tx); |
| 683 | |
| 684 | self.outbox.lock().await.push_back(request.clone()); |
| 685 | self.outbox_notify.notify_waiters(); |
| 686 | let _ = self.outgoing.send(request).await; |
| 687 | |
| 688 | match timeout(wait, response_rx).await { |
| 689 | Ok(Ok(result)) => result, |
| 690 | Ok(Err(_)) => Err("NativeScript inspector response channel closed.".to_owned()), |
| 691 | Err(_) => { |
| 692 | self.pending.lock().await.remove(&id); |
| 693 | Err(format!( |
| 694 | "Timed out waiting for NativeScript inspector method {method}." |
| 695 | )) |
| 696 | } |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | async fn poll(&self, wait: Duration) -> Result<Option<Value>, String> { |
| 701 | let deadline = Instant::now() + wait; |
no test coverage detected