feat(body): remove Sync bound for Body::wrap_stream

A stream wrapped into a Body previously needed to implement `Sync` so
that the Body type implements this autotrait as well (which is needed
due to limitations in async/await). Since a stream only offers one
method that is called with an exclusive reference, this type is
statically proven to be Sync already. In theory it should be fine to add
an `unsafe impl Sync`, but this commit instead adds a SyncWrapper to
enlist the compiler’s help in proving that this is (and remains) correct.

This makes it easier to construct response bodies for client code.
This commit is contained in:
Roland Kuhn
2020-04-19 18:32:17 +02:00
committed by Sean McArthur
parent d5b0ee5672
commit 042c770603
3 changed files with 126 additions and 15 deletions

View File

@@ -13,6 +13,7 @@ pub(crate) mod exec;
pub(crate) mod io;
mod lazy;
mod never;
pub(crate) mod sync_wrapper;
pub(crate) mod task;
pub(crate) mod watch;