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
bool - 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
bool - 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
bool - 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
bool - 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 (const: unstable) · 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<'de> Deserialize<'de> for UpgradeType
impl<'de> Deserialize<'de> for UpgradeType
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<UpgradeType, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<UpgradeType, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
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.
impl Eq for UpgradeType
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
&str- The string slice to parse.
§Returns
Result<Self, Self::Err>- The parsedUpgradeTypevariant; this implementation always returnsOk.
Source§impl PartialEq for UpgradeType
impl PartialEq for UpgradeType
Source§impl Serialize for UpgradeType
impl Serialize for UpgradeType
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for UpgradeType
Auto Trait Implementations§
impl Forget for UpgradeType
impl Freeze for UpgradeType
impl Move for UpgradeType
impl RefUnwindSafe for UpgradeType
impl Send for UpgradeType
impl Sync for UpgradeType
impl Unpin for UpgradeType
impl UnsafeUnpin for UpgradeType
impl UnwindSafe for UpgradeType
Blanket Implementations§
impl<T> AnySend for T
impl<T> AnySendClone for T
impl<T> AnySendSync for T
impl<T> AnySendSyncClone for T
impl<T> AnySync for T
impl<T> AnySyncClone for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.