forked from Nugine/s3s
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upgrade hyper and http-body to 1.x (Nugine#134)
* upgrade hyper and http-body to 1.x * add BoxBody variant * discard non-data frames in Body Stream impl --------- Co-authored-by: Liam Perlaki <liam@perlaki.org>
- Loading branch information
Showing
10 changed files
with
148 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,9 @@ | ||
use std::pin::Pin; | ||
use std::task::Context; | ||
use std::task::Poll; | ||
|
||
use aws_smithy_types::body::SdkBody; | ||
|
||
use futures::Stream; | ||
use hyper::body::HttpBody; | ||
|
||
pub fn s3s_body_into_sdk_body(body: s3s::Body) -> SdkBody { | ||
SdkBody::from_body_0_4(body.boxed()) | ||
SdkBody::from_body_1_x(body) | ||
} | ||
|
||
pub fn sdk_body_into_s3s_body(body: SdkBody) -> s3s::Body { | ||
s3s::Body::from(Box::pin(Wrapper(body)) as s3s::stream::DynByteStream) | ||
} | ||
|
||
struct Wrapper(SdkBody); | ||
|
||
impl Stream for Wrapper { | ||
type Item = Result<bytes::Bytes, s3s::StdError>; | ||
|
||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { | ||
hyper::body::HttpBody::poll_data(Pin::new(&mut self.0), cx) | ||
} | ||
} | ||
|
||
impl s3s::stream::ByteStream for Wrapper { | ||
fn remaining_length(&self) -> s3s::stream::RemainingLength { | ||
hyper::body::HttpBody::size_hint(&self.0).into() | ||
} | ||
s3s::Body::http_body(body) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.