pub enum UpgradeType {
WebSocket,
H2c,
Tls(String),
Unknown(String),
}Expand description
Represents different upgrade types.
Variants§
WebSocket
Represents an upgrade to the WebSocket protocol.
H2c
Represents an upgrade to HTTP/2 cleartext (h2c).
Tls(String)
Represents a TLS upgrade, which is rare and experimental. It includes the specific TLS protocol string.
Unknown(String)
Represents other custom or unknown upgrade protocols, including the protocol string.
Implementations§
Source§impl UpgradeType
impl UpgradeType
Sourcepub fn is_ws(&self) -> bool
pub fn is_ws(&self) -> bool
Checks if the current upgrade type is WebSocket.
§Returns
true if self is Self::WebSocket, otherwise false.
Sourcepub fn is_h2c(&self) -> bool
pub fn is_h2c(&self) -> bool
Checks if the current upgrade type is HTTP/2 cleartext (h2c).
§Returns
true if self is Self::H2c, otherwise false.
Sourcepub fn is_tls(&self) -> bool
pub fn is_tls(&self) -> bool
Checks if the current upgrade type is a TLS variant (any version).
§Returns
true if self matches Self::Tls(_), otherwise false.
Sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
Checks if the current upgrade type is unknown (neither WebSocket, H2c, nor Tls).
§Returns
true if self is none of the known upgrade types, otherwise false.
Trait Implementations§
Source§impl Clone for UpgradeType
impl Clone for UpgradeType
Source§fn clone(&self) -> UpgradeType
fn clone(&self) -> UpgradeType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UpgradeType
impl Debug for UpgradeType
Source§impl Default for UpgradeType
Implements the Default trait for UpgradeType.
impl Default for UpgradeType
Implements the Default trait for UpgradeType.
Provides a default value for UpgradeType, which is Self::Unknown(String::new()).
Source§fn default() -> UpgradeType
fn default() -> UpgradeType
Returns the default UpgradeType, which is Self::Unknown(String::new()).
§Returns
The default UpgradeType instance.
Source§impl Display for UpgradeType
Implements the Display trait for UpgradeType.
This allows UpgradeType variants to be formatted into human-readable strings.
impl Display for UpgradeType
Implements the Display trait for UpgradeType.
This allows UpgradeType variants to be formatted into human-readable strings.
Source§impl FromStr for UpgradeType
Implements the FromStr trait for UpgradeType.
This allows parsing string representations into UpgradeType variants.
impl FromStr for UpgradeType
Implements the FromStr trait for UpgradeType.
This allows parsing string representations into UpgradeType variants.
Source§type Err = ()
type Err = ()
The error type for FromStr implementation, which is a unit type () indicating no specific error information.
Source§fn from_str(
from_str: &str,
) -> Result<UpgradeType, <UpgradeType as FromStr>::Err>
fn from_str( from_str: &str, ) -> Result<UpgradeType, <UpgradeType as FromStr>::Err>
Parses a string slice into an UpgradeType.
The parsing is case-insensitive. It recognizes “websocket”, “h2c”, and strings starting with “tls” as specific types.
Any other string is parsed as Self::Unknown.
§Arguments
from_str: The string slice to parse.
§Returns
Ok(UpgradeType): The parsedUpgradeTypevariant.Err(()): If parsing fails (though this implementation always returnsOk).