pub struct Response { /* private fields */ }Expand description
A response, with the methods of reqwest’s Response that generated clients use.
Implementations§
Source§impl Response
impl Response
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
The status code.
Sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
The headers, to change.
Sourcepub async fn text(self) -> Result<String, Error>
pub async fn text(self) -> Result<String, Error>
Reads the body as text; bytes that are not UTF-8 become U+FFFD.
Sourcepub async fn json<T: DeserializeOwned>(self) -> Result<T, Error>
pub async fn json<T: DeserializeOwned>(self) -> Result<T, Error>
Reads the body as JSON.
Sourcepub fn bytes_stream(
self,
) -> impl Stream<Item = Result<Bytes, Error>> + MaybeSend + 'static
pub fn bytes_stream( self, ) -> impl Stream<Item = Result<Bytes, Error>> + MaybeSend + 'static
The body as a stream of chunks, as they arrive. Send, except on WebAssembly (MaybeSend).
Sourcepub fn events(self) -> Events
pub fn events(self) -> Events
The body as server-sent events (text/event-stream), as they arrive. Events::json
decodes their data: as JSON. The status and the content type are not checked.
Sourcepub async fn save_to(self, path: impl AsRef<Path>) -> Result<u64, Error>
Available on crate feature fs and non-target_family=wasm only.
pub async fn save_to(self, path: impl AsRef<Path>) -> Result<u64, Error>
fs and non-target_family=wasm only.Streams the body to the file at path, and returns the number of bytes written.
The body goes to a temporary file in the same directory, which is flushed to disk (fsync) and then renamed
to path, replacing any file there: path never holds part of a body. When reading the body or writing the
file fails, the temporary file is removed and path is left as it was. The status is not checked.
Sourcepub fn into_async_read(self) -> impl AsyncRead + Send + Unpin + 'static
Available on crate feature fs and non-target_family=wasm only.
pub fn into_async_read(self) -> impl AsyncRead + Send + Unpin + 'static
fs and non-target_family=wasm only.