Closed
Description
As discovered in #285:
This also uncovers some unpleasantness with the current typed headers - not all of the implement the same methods, one mutates in
.value()
, some returnString
orResult<String>
instead ofHeaderValue
, one didn't implementname()
either.
Even if we don't make it a trait the consistency should be fixed in 3.0, but we should probably decide on the trait or-not before doing that work.
Activity
brightly-salty commentedon Dec 19, 2020
Do we want a trait like the following?
yoshuawuyts commentedon Dec 24, 2020
I was thinking something closer to:
There's no need for a separate
to_header
method since bothheader_name
andheader_value
take a shared reference toself
. Getting both is a matter of calling both methods; and any input trait should be able to take tuples of(HeaderName, HeaderValue)
without a problem through a generic impl.There is one more question on how to actually do the conversions to and from the specific typed header types (e.g.
from_headers
), but I think those can continue to live on the actual structs. We should take one step at the time here.Header
trait #315