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

Reimplement StatusCode and HttpVersion using associated constants #1195

Closed
dtolnay opened this Issue May 31, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@dtolnay
Copy link

dtolnay commented May 31, 2017

The associated constants feature is almost ready. rust-lang/rust#29646

Something like:

pub struct StatusCode(pub u16);

impl StatusCode {
    pub const OK: StatusCode = StatusCode(200);
    /* ... */
}

A few advantages:

  • We can easily add new codes as the relevant standards change. Currently adding a new status code would involve a breaking change to hyper.
  • Resolves the ambiguity around whether StatusCode::Ok is equal to StatusCode::Unregistered(200).
  • The size of a status code goes from 4 bytes to 2 bytes which is what it should be.
@seanmonstar

This comment has been minimized.

Copy link
Member

seanmonstar commented Jun 3, 2017

@seanmonstar

This comment has been minimized.

Copy link
Member

seanmonstar commented Sep 17, 2017

This was done in the http crate. The types there will replace the ones here in hyper in v0.12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.