ttpkit_http/client/
response.rs1use std::ops::Deref;
4
5use crate::{Body, Response, ResponseHeader, connection::Upgraded};
6
7pub struct IncomingResponse<B = Body> {
9 inner: Response<B>,
10 upgraded: Option<Upgraded>,
11}
12
13impl<B> IncomingResponse<B> {
14 pub const fn new(response: Response<B>) -> Self {
16 Self {
17 inner: response,
18 upgraded: None,
19 }
20 }
21
22 #[inline]
24 pub fn body(self) -> B {
25 self.inner.body()
26 }
27
28 #[inline]
30 pub fn deconstruct(self) -> (ResponseHeader, B) {
31 self.inner.deconstruct()
32 }
33
34 #[inline]
36 pub fn upgrade(self) -> Option<Upgraded> {
37 self.upgraded
38 }
39
40 pub(crate) fn with_upgraded_connection(mut self, upgraded: Upgraded) -> Self {
42 self.upgraded = Some(upgraded);
43 self
44 }
45}
46
47impl<B> Deref for IncomingResponse<B> {
48 type Target = Response<B>;
49
50 #[inline]
51 fn deref(&self) -> &Self::Target {
52 &self.inner
53 }
54}