Collect the entire contents of this `Body`, and expose them as a string slice. This async fn will be pending until the entire `Body` is copied into memory, or an error occurs. Additonally errors if the contents of the `Body` were not a utf-8 encoded string.
(&mut self)
| 210 | /// copied into memory, or an error occurs. Additonally errors if the |
| 211 | /// contents of the `Body` were not a utf-8 encoded string. |
| 212 | pub async fn str_contents(&mut self) -> Result<&str, Error> { |
| 213 | let bs = self.contents().await?; |
| 214 | std::str::from_utf8(bs).context("decoding body contents as string") |
| 215 | } |
| 216 | |
| 217 | /// Construct a `Body` by serializing a type to json. Can fail with a |
| 218 | /// `serde_json::Error` if serilization fails. |