Have simple-request Response's borrow the Client to ensure it's not prematurely dropped

This commit is contained in:
Luke Parker
2023-11-29 01:16:18 -05:00
parent 51bb434239
commit 8040fedddf
3 changed files with 84 additions and 69 deletions

View File

@@ -4,11 +4,12 @@ use hyper::{
body::{Buf, Body},
};
use crate::Error;
use crate::{Client, Error};
// Borrows the client so its async task lives as long as this response exists.
#[derive(Debug)]
pub struct Response(pub(crate) hyper::Response<Body>);
impl Response {
pub struct Response<'a>(pub(crate) hyper::Response<Body>, pub(crate) &'a Client);
impl<'a> Response<'a> {
pub fn status(&self) -> StatusCode {
self.0.status()
}