Skip to content
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

feat(header): introduce header::Raw #869

Merged
merged 1 commit into from
Jul 23, 2016
Merged

feat(header): introduce header::Raw #869

merged 1 commit into from
Jul 23, 2016

Conversation

seanmonstar
Copy link
Member

The Raw type repesents the raw bytes of a header-value.

Having a special type allows a couple of benefits:

  • The exact representation has become private, allowing "uglier"
    internals. Specifically, since the common case is for a header to only
    have 1 line of bytes, an enum is used to skip allocating a Vec for only
    1 line. Additionally, a Cow<'static, [u8]> is used, so static bytes
    don't require a copy. Finally, since we can use static bytes, when
    parsing, we can compare the incoming bytes against a couple of the most
    common header-values, and possibly remove another copy.
  • As its own type, the Headers.set_raw method can be generic over
    Into<Raw>, which allows for more ergnomic method calls.

BREAKING CHANGE: Header::parse_header now receives &Raw, instead of
a &[Vec<u8>]. Raw provides several methods to ease using it, but
may require some changes to existing code.

The Raw type repesents the raw bytes of a header-value.

Having a special type allows a couple of benefits:

- The exact representation has become private, allowing "uglier"
internals. Specifically, since the common case is for a header to only
have 1 line of bytes, an enum is used to skip allocating a Vec for only
1 line. Additionally, a Cow<'static, [u8]> is used, so static bytes
don't require a copy. Finally, since we can use static bytes, when
parsing, we can compare the incoming bytes against a couple of the most
common header-values, and possibly remove another copy.

- As its own type, the `Headers.set_raw` method can be generic over
`Into<Raw>`, which allows for more ergnomic method calls.

BREAKING CHANGE: `Header::parse_header` now receives `&Raw`, instead of
  a `&[Vec<u8>]`. `Raw` provides several methods to ease using it, but
  may require some changes to existing code.
@seanmonstar
Copy link
Member Author

cc @mitsuhiko

@seanmonstar seanmonstar merged commit 50ccdaa into master Jul 23, 2016
@seanmonstar seanmonstar deleted the headers-raw branch July 23, 2016 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant