-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Chunk in favor of using Bytes directly #1931
Comments
I'm a firm +1 to this suggestion. I'd also be okay with maybe replacing |
I haven't checked if |
I think it might be, but I’m not qualified to give an answer on that at the moment. Disregard my comment about Bytes! |
This could work out. I'd just hope all the same convenient constructors match up (I think in bytes 0.4, |
When you say "same convenient constructors match up", are you referring to the constructors on Bytes in 0.5.x, or something else? |
Yea, I think my concerns are fixed in 0.5.x, so I'd probably wait until that is available before making the change in hyper. |
@seanmonstar , I interpreted this issue as implying that you wanted to make Chunk into a type alias, but it's also possible that you intended that Chunk should be removed entirely. I've just submitted a PR for the former. |
Closes #1931 BREAKING CHANGE: All usage of `hyper::Chunk` should be replaced with `bytes::Bytes` (or `hyper::body::Bytes`).
Closes #1931 BREAKING CHANGE: All usage of `hyper::Chunk` should be replaced with `bytes::Bytes` (or `hyper::body::Bytes`).
Closes #1931 BREAKING CHANGE: All usage of `hyper::Chunk` should be replaced with `bytes::Bytes` (or `hyper::body::Bytes`).
Compared to
Bytes
,Chunk
is pointless and kinda frustrating:Bytes
butBytes
is exposed via theFrom
/Into
impl anyways so it's not like it's keeping it out of the public APIChunk
adds 0 new functionality overBytes
, all of its methods forwards toBytes
anywayChunk
without round-tripping throughBytes
Stream<Item = Bytes>
needs special adapters to work withhyper::Body
That last one is a real problem for me because I'm finally updating
multipart-async
and trying to maximize interop by generifying the API as much as possible. Becausehyper::Body
doesn't implementAsyncRead
I've instead standardized around aStream<Item = impl BodyChunk>
API whereBodyChunk
covers two operations: splitting and dereffing to&[u8]
. My final constraint is that I want to be able to return the sameimpl BodyChunk
type, mostly to make it easy to dropmultipart-async
into existing request handlers.Without implementing
BodyChunk
specifically forhyper::Chunk
while still having an applicable impl for it, I would need an impl that's generic overT: From<Bytes>, Bytes: From<T>, T: AsRef<[u8]>
. My hangup on this is that I now cannot implementBodyChunk
for&[u8]
directly, which complicates testing as I have to convert all bytestring literals toBytes
. (I also want to avoid a generic impl based onInto<Bytes>
as that operation may perform implicit copies and I'm trying to be near-zero-copy.)I realize
Chunk
exists because it used to be a custom implementation ofBytes
but at this point it can be changed to just be a type alias and basically nothing will break (except usages ofChunk::into_bytes()
, ironically).The text was updated successfully, but these errors were encountered: