Skip to content
This repository was archived by the owner on Jun 21, 2020. It is now read-only.

Commit 515d066

Browse files
committed
implement feedback
Signed-off-by: Yoshua Wuyts <[email protected]>
1 parent 9826710 commit 515d066

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

http-service-hyper/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ where
7676
.map(|chunk| chunk.map(|chunk| chunk.to_vec()))
7777
.map_err(|e| io::Error::new(io::ErrorKind::Other, e));
7878
let body_reader = body_stream.into_async_read();
79-
Body::from_reader(Box::new(body_reader))
79+
Body::from_reader(body_reader)
8080
});
8181

8282
let fut = self.service.respond(&mut self.connection, req);

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ pin_project_lite::pin_project! {
1818
/// The raw body of an http request or response.
1919
pub struct Body {
2020
#[pin]
21-
reader: Box<dyn BufRead + Unpin + Send + 'static>,
21+
reader: Pin<Box<dyn BufRead + Send + 'static>>,
2222
}
2323
}
2424

2525
impl Body {
2626
/// Create a new empty body.
2727
pub fn empty() -> Self {
2828
Self {
29-
reader: Box::new(io::empty()),
29+
reader: Box::pin(io::empty()),
3030
}
3131
}
3232

3333
/// Create a new instance from a reader.
3434
pub fn from_reader(reader: impl BufRead + Unpin + Send + 'static) -> Self {
3535
Self {
36-
reader: Box::new(reader),
36+
reader: Box::pin(reader),
3737
}
3838
}
3939
}
@@ -68,14 +68,14 @@ impl fmt::Debug for Body {
6868
impl From<Vec<u8>> for Body {
6969
fn from(vec: Vec<u8>) -> Body {
7070
Self {
71-
reader: Box::new(io::Cursor::new(vec)),
71+
reader: Box::pin(io::Cursor::new(vec)),
7272
}
7373
}
7474
}
7575

76-
impl<R: BufRead + Unpin + Send + 'static> From<Box<R>> for Body {
76+
impl<R: BufRead + Unpin + Send + 'static> From<Pin<Box<R>>> for Body {
7777
/// Converts an `AsyncRead` into a Body.
78-
fn from(reader: Box<R>) -> Self {
78+
fn from(reader: Pin<Box<R>>) -> Self {
7979
Self { reader }
8080
}
8181
}

0 commit comments

Comments
 (0)