pub struct StreamResponse {
pub url: Url,
pub status: StatusCode,
pub headers: HeaderMap,
pub body_stream: Pin<Box<dyn Stream<Item = Result<Bytes, Error>> + Send>>,
pub request_url: Url,
pub meta: DashMap<Cow<'static, str>, Value>,
pub cached: bool,
}Expand description
A stream response that allows processing of large responses without loading the entire body into memory at once.
Fields§
§url: UrlThe final URL of the response after any redirects.
status: StatusCodeThe HTTP status code of the response.
headers: HeaderMapThe headers of the response.
body_stream: Pin<Box<dyn Stream<Item = Result<Bytes, Error>> + Send>>The body of the response as a stream of Bytes chunks.
request_url: UrlThe original URL of the request that led to this response.
meta: DashMap<Cow<'static, str>, Value>Metadata associated with the response, carried over from the request.
cached: boolIndicates if the response was served from a cache.
Implementations§
Source§impl StreamResponse
impl StreamResponse
Sourcepub async fn to_response(self) -> Result<Response, Error>
pub async fn to_response(self) -> Result<Response, Error>
Converts the stream response to a regular response by collecting all body chunks. This defeats the purpose of streaming but provides compatibility with existing code.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StreamResponse
impl !RefUnwindSafe for StreamResponse
impl Send for StreamResponse
impl !Sync for StreamResponse
impl Unpin for StreamResponse
impl !UnwindSafe for StreamResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more