Skip to content

HTTP Version type #2

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

Closed
seanmonstar opened this issue Mar 15, 2017 · 2 comments
Closed

HTTP Version type #2

seanmonstar opened this issue Mar 15, 2017 · 2 comments

Comments

@seanmonstar
Copy link
Member

Similar to the reasoning in #1, I've an initial design that replaces hyper's enum with an opaque struct, allowing adding new HTTP versions in the future (HTTP2 spec says 3 could happen).

https://github.com/seanmonstar/http-rs/blob/50b7cb555ae3445d37ae20edfddb756d70fdf22d/src/version.rs

pub struct Version(Http);

impl Version {
    // .. constructors for each version
    pub fn http_11() -> Version {
        Version(Http::Http11)
    }

    // .. instance methods
    pub fn major(&self) -> u8 {
        match self.0 {
            Http09 => 0
            Http10 |
            Http11 => 1,
            H2     |
            H2c    => 2,    
        }
    }
}

enum Http {
    Http11,
    // ...version variants
}
@alexcrichton
Copy link
Contributor

👍

@carllerche
Copy link
Collaborator

Resolved by #is 7

thomaseizinger pushed a commit to thomaseizinger/http that referenced this issue Nov 10, 2018
Miscellaneous doc improvements
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

No branches or pull requests

3 participants