Skip to content

Commit 80ddb2b

Browse files
Fuuzetsubenesch
authored andcommitted
Remove unnecessary Sync constraint on ByteStream
Whole package seems to compile without it. Closes rusoto#1896. This should allow to create ByteStreams from streams that are !Sync.
1 parent bcf8048 commit 80ddb2b

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
match `rusoto_credential`
1212
- Swap the non-RustCrypto `md5` crate for the RustCrypto `md-5` crate, to match
1313
usage of RustCrypto `sha2` crate
14-
14+
- Remove `Sync` constraint on `ByteStream`-related functions.
1515
## [0.46.0] - 2021-01-05
1616

1717
- Display `rusoto_core::Client` in docs

rusoto/signature/src/stream.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ pin_project! {
1313
pub struct ByteStream {
1414
size_hint: Option<usize>,
1515
#[pin]
16-
inner: Pin<Box<dyn Stream<Item = Result<Bytes, io::Error>> + Send + Sync + 'static>>,
16+
inner: Pin<Box<dyn Stream<Item = Result<Bytes, io::Error>> + Send + 'static>>,
1717
}
1818
}
1919

2020
impl ByteStream {
2121
/// Create a new `ByteStream` by wrapping a `futures` stream.
2222
pub fn new<S>(stream: S) -> ByteStream
2323
where
24-
S: Stream<Item = Result<Bytes, io::Error>> + Send + Sync + 'static,
24+
S: Stream<Item = Result<Bytes, io::Error>> + Send + 'static,
2525
{
2626
ByteStream {
2727
size_hint: None,
@@ -33,7 +33,7 @@ impl ByteStream {
3333
/// size_hint to satisy S3's `PutObject` API.
3434
pub fn new_with_size<S>(stream: S, size_hint: usize) -> ByteStream
3535
where
36-
S: Stream<Item = Result<Bytes, io::Error>> + Send + Sync + 'static,
36+
S: Stream<Item = Result<Bytes, io::Error>> + Send + 'static,
3737
{
3838
ByteStream {
3939
size_hint: Some(size_hint),
@@ -46,12 +46,12 @@ impl ByteStream {
4646
}
4747

4848
/// Return an implementation of `AsyncRead` that uses async i/o to consume the stream.
49-
pub fn into_async_read(self) -> impl AsyncRead + Send + Sync {
49+
pub fn into_async_read(self) -> impl AsyncRead + Send {
5050
ImplAsyncRead::new(self.inner)
5151
}
5252

5353
/// Return an implementation of `Read` that uses blocking i/o to consume the stream.
54-
pub fn into_blocking_read(self) -> impl io::Read + Send + Sync {
54+
pub fn into_blocking_read(self) -> impl io::Read + Send {
5555
ImplBlockingRead::new(self.inner)
5656
}
5757
}
@@ -84,12 +84,12 @@ pin_project! {
8484
struct ImplAsyncRead {
8585
buffer: BytesMut,
8686
#[pin]
87-
stream: futures::stream::Fuse<Pin<Box<dyn Stream<Item = Result<Bytes, io::Error>> + Send + Sync>>>,
87+
stream: futures::stream::Fuse<Pin<Box<dyn Stream<Item = Result<Bytes, io::Error>> + Send>>>,
8888
}
8989
}
9090

9191
impl ImplAsyncRead {
92-
fn new(stream: Pin<Box<dyn Stream<Item = Result<Bytes, io::Error>> + Send + Sync>>) -> Self {
92+
fn new(stream: Pin<Box<dyn Stream<Item = Result<Bytes, io::Error>> + Send>>) -> Self {
9393
ImplAsyncRead {
9494
buffer: BytesMut::new(),
9595
stream: stream.fuse(),
@@ -128,7 +128,7 @@ pin_project! {
128128
}
129129

130130
impl ImplBlockingRead {
131-
fn new(stream: Pin<Box<dyn Stream<Item = Result<Bytes, io::Error>> + Send + Sync>>) -> Self {
131+
fn new(stream: Pin<Box<dyn Stream<Item = Result<Bytes, io::Error>> + Send>>) -> Self {
132132
ImplBlockingRead {
133133
inner: ImplAsyncRead::new(stream),
134134
}
@@ -140,7 +140,11 @@ impl io::Read for ImplBlockingRead {
140140
let rt = tokio::runtime::Runtime::new()?;
141141
rt.block_on(future::poll_fn(|cx| {
142142
let mut buf = ReadBuf::new(buf);
143-
futures::ready!(AsyncRead::poll_read(Pin::new(&mut self.inner), cx, &mut buf))?;
143+
futures::ready!(AsyncRead::poll_read(
144+
Pin::new(&mut self.inner),
145+
cx,
146+
&mut buf
147+
))?;
144148
Poll::Ready(Ok(buf.filled().len()))
145149
}))
146150
}

0 commit comments

Comments
 (0)