Perform a request and deserialize the JSON response.
(
&self,
method: hyper::Method,
path: &str,
body: Option<&Value>,
)
| 360 | |
| 361 | /// Perform a request and deserialize the JSON response. |
| 362 | async fn request_json<T: DeserializeOwned>( |
| 363 | &self, |
| 364 | method: hyper::Method, |
| 365 | path: &str, |
| 366 | body: Option<&Value>, |
| 367 | ) -> Result<T, PodmanApiError> { |
| 368 | let (status, bytes) = self.request(method, path, body, API_TIMEOUT).await?; |
| 369 | if status.is_success() { |
| 370 | serde_json::from_slice(&bytes).map_err(|e| { |
| 371 | PodmanApiError::Json(format!("{e}: {}", String::from_utf8_lossy(&bytes))) |
| 372 | }) |
| 373 | } else { |
| 374 | Err(error_from_response(status.as_u16(), &bytes)) |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | /// Perform a request that returns no meaningful body. |
| 379 | async fn request_ok( |
no test coverage detected