(self)
| 97 | } |
| 98 | |
| 99 | async fn json_or_error<T: serde::de::DeserializeOwned>(self) -> anyhow::Result<T> { |
| 100 | let status = self.status(); |
| 101 | self.ensure_content_type("application/json") |
| 102 | .await? |
| 103 | .json() |
| 104 | .await |
| 105 | .map_err(|err| { |
| 106 | let mut err = anyhow::Error::from(err); |
| 107 | if let Some(desc) = err_status_desc(status) { |
| 108 | err = err.context(format!("malformed json payload for {desc} ({status})")) |
| 109 | } |
| 110 | err |
| 111 | }) |
| 112 | } |
| 113 | |
| 114 | fn found(self) -> Option<Self> { |
| 115 | (self.status() != http::StatusCode::NOT_FOUND).then_some(self) |
no test coverage detected