MCPcopy Create free account
hub / github.com/bytecodealliance/wstd / str_contents

Method str_contents

src/http/body.rs:212–215  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 1

jsonMethod · 0.80

Calls 1

contentsMethod · 0.80

Tested by

no test coverage detected