pub enum HttpVersion {
HTTP0_9,
HTTP1_0,
HTTP1_1,
HTTP2,
HTTP3,
Unknown(String),
}Expand description
Represents the HTTP version used in the request or response.
This enum defines the various HTTP protocol versions supported,
including HTTP/0.9, HTTP/1.0, HTTP/1.1, HTTP/2, and HTTP/3.
It also includes an Unknown variant for unrecognized versions.
Variants§
HTTP0_9
HTTP version 0.9
HTTP1_0
HTTP version 1.0
HTTP1_1
HTTP version 1.1
HTTP2
HTTP version 2.0
HTTP3
HTTP version 3.0
Unknown(String)
Unknown version
Implementations§
Source§impl HttpVersion
impl HttpVersion
Sourcepub fn is_http0_9(&self) -> bool
pub fn is_http0_9(&self) -> bool
Checks if the current version is HTTP/0.9.
§Returns
true if the version is HTTP/0.9, false otherwise.
Sourcepub fn is_http1_0(&self) -> bool
pub fn is_http1_0(&self) -> bool
Checks if the current version is HTTP/1.0.
§Returns
true if the version is HTTP/1.0, false otherwise.
Sourcepub fn is_http1_1(&self) -> bool
pub fn is_http1_1(&self) -> bool
Checks if the current version is HTTP/1.1.
§Returns
true if the version is HTTP/1.1, false otherwise.
Sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
Sourcepub fn is_http1_1_or_higher(&self) -> bool
pub fn is_http1_1_or_higher(&self) -> bool
Checks if the current version is HTTP/1.1 or higher.
§Returns
true if the version is HTTP/1.1, HTTP/2, or HTTP/3, false otherwise.
Trait Implementations§
Source§impl Clone for HttpVersion
impl Clone for HttpVersion
Source§fn clone(&self) -> HttpVersion
fn clone(&self) -> HttpVersion
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HttpVersion
impl Debug for HttpVersion
Source§impl Default for HttpVersion
Implements the Default trait for HttpVersion.
impl Default for HttpVersion
Implements the Default trait for HttpVersion.
Source§fn default() -> HttpVersion
fn default() -> HttpVersion
Returns the default HttpVersion variant, which is Unknown with an empty string.
§Returns
The default HttpVersion variant.
Source§impl Display for HttpVersion
Implements the Display trait for HttpVersion, allowing it to be formatted as a string.
impl Display for HttpVersion
Implements the Display trait for HttpVersion, allowing it to be formatted as a string.
Source§impl FromStr for HttpVersion
Implements the FromStr trait for HttpVersion, allowing conversion from a string slice.
impl FromStr for HttpVersion
Implements the FromStr trait for HttpVersion, allowing conversion from a string slice.
Source§fn from_str(
version_str: &str,
) -> Result<HttpVersion, <HttpVersion as FromStr>::Err>
fn from_str( version_str: &str, ) -> Result<HttpVersion, <HttpVersion as FromStr>::Err>
Converts a string slice into an HttpVersion variant.
This method attempts to parse the input string into a known HttpVersion variant.
If the string does not match any known version, it returns an Unknown variant
containing the original string.
§Arguments
version_str- The string slice to convert.
§Returns
A Result containing the HttpVersion variant if successful, or Self::Err on failure.