30 lines
691 B
Rust
30 lines
691 B
Rust
#[derive(Debug, PartialEq)]
|
|
pub enum HTTPVersion {
|
|
Http1_0,
|
|
Http1_1,
|
|
Http2,
|
|
Unknown,
|
|
}
|
|
|
|
impl Into<String> for HTTPVersion {
|
|
fn into(self) -> String {
|
|
match self {
|
|
Self::Http1_0 => "HTTP/1.0".to_string(),
|
|
Self::Http1_1 => "HTTP/1.1".to_string(),
|
|
Self::Http2 => "HTTP/2".to_string(),
|
|
Self::Unknown => "UNKNOWN".to_string(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<&str> for HTTPVersion {
|
|
fn from(http_version: &str) -> Self {
|
|
match http_version {
|
|
"HTTP/1.0" => Self::Http1_0,
|
|
"HTTP/1.1" => Self::Http1_1,
|
|
"HTTP/2" => Self::Http2,
|
|
_ => Self::Unknown,
|
|
}
|
|
}
|
|
}
|