use crate::prelude::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(deny_unknown_fields))]
pub enum SpecialNotFileSchemeDetails {
Http ,
Https,
Ws ,
Wss ,
Ftp ,
}
impl SpecialNotFileSchemeDetails {
pub const fn as_str(self) -> &'static str {
match self {
Self::Http => "http" ,
Self::Https => "https",
Self::Ws => "ws" ,
Self::Wss => "wss" ,
Self::Ftp => "ftp" ,
}
}
pub const fn r#type(self) -> SchemeType {
SchemeType::SpecialNotFile
}
pub fn is_http (self) -> bool {matches!(self, Self::Http )}
pub fn is_https (self) -> bool {matches!(self, Self::Https )}
pub fn is_http_or_https(self) -> bool {matches!(self, Self::Http | Self::Https)}
pub fn is_ws (self) -> bool {matches!(self, Self::Ws )}
pub fn is_wss (self) -> bool {matches!(self, Self::Wss )}
pub fn is_ws_or_wss (self) -> bool {matches!(self, Self::Ws | Self::Wss )}
pub fn is_ftp (self) -> bool {matches!(self, Self::Ftp )}
pub fn default_port(self) -> Port<'static> {
unsafe {Port::new_unchecked(self.default_port_str(), self.default_port_num())}
}
pub const fn default_port_num(self) -> u16 {
match self {
Self::Http | Self::Ws => 80,
Self::Https | Self::Wss => 443,
Self::Ftp => 21,
}
}
pub const fn default_port_str(self) -> &'static str {
match self {
Self::Http | Self::Ws => "80",
Self::Https | Self::Wss => "443",
Self::Ftp => "21",
}
}
}