(
&self,
action: &'static Action,
body: Action::RequestBody,
)
| 90 | } |
| 91 | |
| 92 | async fn vm_action<Action: ApiAction<ResponseBody = Option<Body>>>( |
| 93 | &self, |
| 94 | action: &'static Action, |
| 95 | body: Action::RequestBody, |
| 96 | ) -> Result<Optional<String>> { |
| 97 | let api_sender = self.clone_api_sender().await; |
| 98 | let api_notifier = self.clone_api_notifier()?; |
| 99 | |
| 100 | let result = blocking::unblock(move || action.send(api_notifier, api_sender, body)) |
| 101 | .await |
| 102 | .map_err(api_error)? |
| 103 | // We're using `from_utf8_lossy` here to not deal with the |
| 104 | // error case of `from_utf8` as we know that `b.body` is valid JSON. |
| 105 | .map(|b| String::from_utf8_lossy(&b.body).to_string()); |
| 106 | |
| 107 | Ok(result.into()) |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | #[interface(name = "org.cloudhypervisor.DBusApi1")] |
no test coverage detected