Dispatch one server-side event and then return. Just so we have a nicer looking `select` statement in `run` :-)
(
&self,
input: &mut FramedRead<I, JsonRpcCodec>,
plugin: &Plugin<S>,
)
| 524 | /// Dispatch one server-side event and then return. Just so we |
| 525 | /// have a nicer looking `select` statement in `run` :-) |
| 526 | async fn dispatch_one<I>( |
| 527 | &self, |
| 528 | input: &mut FramedRead<I, JsonRpcCodec>, |
| 529 | plugin: &Plugin<S>, |
| 530 | ) -> Result<(), Error> |
| 531 | where |
| 532 | I: Send + AsyncReadExt + Unpin, |
| 533 | { |
| 534 | match input.next().await { |
| 535 | Some(Ok(msg)) => { |
| 536 | trace!("Received a message: {:?}", msg); |
| 537 | match msg { |
| 538 | messages::JsonRpc::Request(id, p) => { |
| 539 | PluginDriver::<S>::dispatch_request(id, p, plugin).await |
| 540 | } |
| 541 | messages::JsonRpc::Notification(n) => { |
| 542 | self.dispatch_notification(n, plugin).await |
| 543 | } |
| 544 | messages::JsonRpc::CustomRequest(id, p) => { |
| 545 | match self.dispatch_custom_request(id.clone(), p, plugin).await { |
| 546 | Ok(v) => plugin |
| 547 | .sender |
| 548 | .send(json!({ |
| 549 | "jsonrpc": "2.0", |
| 550 | "id": id, |
| 551 | "result": v |
| 552 | })) |
| 553 | .await |
| 554 | .context("returning custom result"), |
| 555 | Err(e) => plugin |
| 556 | .sender |
| 557 | .send(json!({ |
| 558 | "jsonrpc": "2.0", |
| 559 | "id": id, |
| 560 | "error": e.to_string(), |
| 561 | })) |
| 562 | .await |
| 563 | .context("returning custom error"), |
| 564 | } |
| 565 | } |
| 566 | messages::JsonRpc::CustomNotification(n) => { |
| 567 | self.dispatch_custom_notification(n, plugin).await |
| 568 | } |
| 569 | } |
| 570 | } |
| 571 | Some(Err(e)) => Err(anyhow!("Error reading command: {}", e)), |
| 572 | None => Err(anyhow!("Error reading from master")), |
| 573 | } |
| 574 | } |
| 575 | |
| 576 | async fn dispatch_request( |
| 577 | _id: serde_json::Value, |
nothing calls this directly
no test coverage detected