Run the plugin until we get a shutdown command.
(
self,
mut receiver: tokio::sync::mpsc::Receiver<serde_json::Value>,
mut input: FramedRead<I, JsonRpcCodec>,
output: Arc<Mutex<FramedWrite<O, JsonCodec>>>,
)
| 901 | { |
| 902 | /// Run the plugin until we get a shutdown command. |
| 903 | async fn run<I, O>( |
| 904 | self, |
| 905 | mut receiver: tokio::sync::mpsc::Receiver<serde_json::Value>, |
| 906 | mut input: FramedRead<I, JsonRpcCodec>, |
| 907 | output: Arc<Mutex<FramedWrite<O, JsonCodec>>>, |
| 908 | ) -> Result<(), Error> |
| 909 | where |
| 910 | I: Send + AsyncReadExt + Unpin, |
| 911 | O: Send + AsyncWriteExt + Unpin, |
| 912 | { |
| 913 | loop { |
| 914 | // If we encounter any error reading or writing from/to |
| 915 | // the master we hand them up, so we can return control to |
| 916 | // the user-code, which may require some cleanups or |
| 917 | // similar. |
| 918 | tokio::select! { |
| 919 | e = self.dispatch_one(&mut input, &self.plugin) => { |
| 920 | if let Err(e) = e { |
| 921 | return Err(e) |
| 922 | } |
| 923 | }, |
| 924 | v = receiver.recv() => { |
| 925 | output.lock().await.send( |
| 926 | v.context("internal communication error")? |
| 927 | ).await?; |
| 928 | }, |
| 929 | } |
| 930 | } |
| 931 | } |
| 932 | |
| 933 | /// Dispatch one server-side event and then return. Just so we |
| 934 | /// have a nicer looking `select` statement in `run` :-) |
no outgoing calls
no test coverage detected