A type to represent a valid HeaderValue and String
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.4k
- Forks
- 378
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 5
Description
A HeaderValue may not always be a valid UTF-8 String, and so there is a to_str(&self) -> Result<&str, ToStrError> method that validates the bytes first. To create a String, one could instead do String::from_utf8(value.as_bytes()), but once you have that String, you'll need to re-validate it to turn it back into a HeaderValue.
It would be useful to have a type that represents being both a valid HeaderValue and a valid String at the same time. This type would have a free as_str() method, since it's already been validated, and conversely a free into_value() method (again, because it's already validated).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing HeaderValue type and its to_str(&self) conversion, then compare the proposed type with String::from_utf8(value.as_bytes()). Decide the type's API and conversion behavior, including as_str() and into_value(); it is done when both valid String and HeaderValue representations can be used without repeated validation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100