pub trait ClientResponse:
Send
+ Sync
+ Sized {
type ResponseError: DecodeError + Send;
type StreamError: Error + Send + Sync;
type Headers: ResponseHeaders;
// Required methods
fn content_length(&self) -> Option<u64>;
fn content_type(&self) -> Option<&str>;
fn headers(&self) -> Self::Headers;
fn into_result(self) -> Result<Self, Self::ResponseError>;
fn stream(
self,
) -> Box<dyn Stream<Item = Result<Bytes, Self::StreamError>> + Unpin + Send + Sync>;
}
http
only.Expand description
A wrapper trait for an HTTP response that exposes only functionality necessary for retrieving
the stream content. If the reqwest
feature is enabled,
this trait is implemented for
reqwest::Response.
This can be implemented for a custom HTTP response if desired.
Required Associated Types§
Sourcetype ResponseError: DecodeError + Send
type ResponseError: DecodeError + Send
Error type returned by the underlying response.
Sourcetype StreamError: Error + Send + Sync
type StreamError: Error + Send + Sync
Error type returned by the stream.
Sourcetype Headers: ResponseHeaders
type Headers: ResponseHeaders
Object containing HTTP response headers.
Required Methods§
Sourcefn content_length(&self) -> Option<u64>
fn content_length(&self) -> Option<u64>
The size of the remote resource in bytes.
The result should be None
if the stream is infinite or doesn’t have a known length.
Sourcefn content_type(&self) -> Option<&str>
fn content_type(&self) -> Option<&str>
The content-type response header.
This should be in the standard format of <type>/<subtype>
.
Sourcefn into_result(self) -> Result<Self, Self::ResponseError>
fn into_result(self) -> Result<Self, Self::ResponseError>
Turns the response into an error if the response was not successful.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl ClientResponse for Response
Available on crate feature reqwest
only.
impl ClientResponse for Response
reqwest
only.