http v0.2
A couple years ago, we released the beginning of the http
crate. It’s purpose was to allow a common API for the ecosystem to interact with HTTP types, without those types referring to a specific implementation. We’ve seen great things sprout up since then!
Today marks the 0.2 release, a chance to make some minor breaking changes, with the hopes that this 0.2 version can soon just be promoted to 1.0. So, what has changed?
HTTP/3
A seemingly simple change is adding the Version::HTTP_3
constant. However, we couldn’t add it in 0.1 due to an unexpected compiler behavior that allowed exhaustive matching on the Version
constants even though the internal enum
wasn’t exposed. This time, we’ve made sure to prevent exhaustive matches, so we can add new versions in the future.
Builders are now by-value
There are some pretty useful builders to construct a Request
, Response
, or Uri
. In 0.1, they were “by-reference” builders, meaning that each builder method took &mut self
and returned &mut Builder
. Now, they take self
and return Builder
. There’s pros and cons for each pattern, but the weightiest one that made us change was the nature of “consuming” the builder once finished. To “build” a “by-ref” builder requires that either the data inside be cloned, or the builder be left in a “don’t build me again” state. This change now makes it clearer that a builder cannot used again, as it will now be a compiler error.
Reduced public dependencies
To help meet the goal of promoting to http
v1.0, we’ve reduced the number of public dependencies to 0. There’s still a way to make use of bytes
to reduce copies, but it’s now exposed in a way that there’s no API contract. This allows http
to reach 1.0 even if bytes
takes longer.
Next
We expect the ecosystem to start updating to http
0.2 so you all can have the improvements as soon as possible. For example, hyper should also be ready hopefully this week. Check the changelog for the full details!