-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add IntoResponse impl for BytesMut and Chain #767
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I had an idea regarding Chain
. Let me know what you think :)
You can just ignore the cargo deny CI failure. I'll get that fixed at some point 😊 |
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
420e19e
to
907c8d6
Compare
axum/CHANGELOG.md
Outdated
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
|
|||
- **added:** `middleware::from_fn` for creating middleware from async functions. | |||
This previously lived in axum-extra but has been moved to axum ([#719]) | |||
- **added:** Implement `IntoResponse` for `bytes::BytesMut` and `bytes::Chain<T, U>` ([#767]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I knew this could come up at some point. This change was actually made in axum-core so it should at least be mentioned in its changelog as well. The question is whether it should be mentioned in axum's as well. The heuristic I've used so far is that only significant changes are mentioned in both. I kinda feel this isn't very significant so should only be in axum-core's changelog.
@jplatte wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't notice that there was a changelog specific to subcrates, I believe you're correct, this isn't worth a line in the "main" changelog. I'll move that there :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this won't be very helpful, but I don't care much either way 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jplatte thats a first 😂
Re-implemented Also squashed commits to keep a clean history :) |
907c8d6
to
ed8433f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT! Thanks!
We squash merge all PRs so you actually don't have to. |
* Add IntoResponse impl for BytesMut and Chain Co-authored-by: David Pedersen <david.pdrsn@gmail.com> * Add CHANGELOG entry Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
* Add IntoResponse impl for BytesMut and Chain Co-authored-by: David Pedersen <david.pdrsn@gmail.com> * Add CHANGELOG entry Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
Adds two
IntoResponse
implementations for convenience to work onbytes
typesMotivation
bytes
cratebytes::Chain
seemed like a good opportunity to do so.Solution
Two new implementations of IntoResponse :
BytesMut
which freezes (zero-cost operation) to get aBytes
handle and use its IntoResponse's implementation.Chain<T,U>
whereT: Buf
andU: Buf
, which iterates over every collects everything into aBytes
. Sadly the implementation ofFromIterator
seems to show that it's not exactly zero-cost.