Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #286
This PR implements the
Header
trait, creating a unified interface for the convention we had ofTypedHeader::{value, name, apply}
. This instead enables an interface of:Because
header_name
andheader_value
have to be implemented,apply_header
has a default implementation. This should make it easier to keep up to date.Breaking changes
This patch doesn't break anything, but it does set us up for the 3.0.0 release. When we're ready to implement the 3.0.0 changes we should remove the
name
,value
andapply
methods in favor of keeping the trait only. This patch also explicitly chose to keep thevalue
method implementation where it is in order to not create a massive merge conflict with #313.Bug fixes
This patch also fixes two bugs: a wrong header name in
TE
and inTransferEncoding
. These have been adjusted and now use the right header name.Prior work
This patch serves as an alternative to #285, implementing the design I referenced in #285 (comment).
Future directions
We should consider taking a look at the
headers
submodule in general. A few changes I think would be worthwhile:HeaderName
instead.Headers
toHeaderMap
, matching thehyperium/hyper
naming conventionToHeaderValues
from an associated iterator to be an instance ofHeaderValues
instead. The trait precedes the concrete type, and having a trait and a type with similar names be completely unrelated feels awkward.AsRef
andAsMut
implementations are provided.http_types::headers
crate-level docs with an explainer of the different types in the crate.