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 SpecialSchemeDetails {
File (FileSchemeDetails ),
SpecialNotFile(SpecialNotFileSchemeDetails),
}
impl SpecialSchemeDetails {
pub const FILE : Self = Self::File (FileSchemeDetails );
pub const HTTP : Self = Self::SpecialNotFile(SpecialNotFileSchemeDetails::Http );
pub const HTTPS: Self = Self::SpecialNotFile(SpecialNotFileSchemeDetails::Https);
pub const WS : Self = Self::SpecialNotFile(SpecialNotFileSchemeDetails::Ws );
pub const WSS : Self = Self::SpecialNotFile(SpecialNotFileSchemeDetails::Wss );
pub const FTP : Self = Self::SpecialNotFile(SpecialNotFileSchemeDetails::Ftp );
pub const fn as_str(self) -> &'static str {
match self {
Self::File (x) => x.as_str(),
Self::SpecialNotFile(x) => x.as_str(),
}
}
pub const fn r#type(self) -> SchemeType {
match self {
Self::File (x) => x.r#type(),
Self::SpecialNotFile(x) => x.r#type(),
}
}
pub const fn is_special_not_file(self) -> bool {matches!(self, Self::SpecialNotFile(_))}
pub const fn is_file (self) -> bool {matches!(self, Self::FILE )}
pub const fn is_http (self) -> bool {matches!(self, Self::HTTP )}
pub const fn is_https (self) -> bool {matches!(self, Self::HTTPS )}
pub const fn is_http_or_https(self) -> bool {matches!(self, Self::HTTP | Self::HTTPS)}
pub const fn is_ws (self) -> bool {matches!(self, Self::WS )}
pub const fn is_wss (self) -> bool {matches!(self, Self::WSS )}
pub const fn is_ws_or_wss (self) -> bool {matches!(self, Self::WS | Self::WSS )}
pub const fn is_ftp (self) -> bool {matches!(self, Self::FTP )}
pub fn default_port(self) -> Option<Port<'static>> {
match self {
Self::File (_) => None,
Self::SpecialNotFile(x) => Some(x.default_port()),
}
}
pub const fn default_port_num(self) -> Option<u16> {
match self {
Self::File (_) => None,
Self::SpecialNotFile(x) => Some(x.default_port_num()),
}
}
pub const fn default_port_str(self) -> Option<&'static str> {
match self {
Self::File (_) => None,
Self::SpecialNotFile(x) => Some(x.default_port_str()),
}
}
}
impl From<FileSchemeDetails > for SpecialSchemeDetails {fn from(value: FileSchemeDetails ) -> Self {Self::File (value)}}
impl From<SpecialNotFileSchemeDetails> for SpecialSchemeDetails {fn from(value: SpecialNotFileSchemeDetails) -> Self {Self::SpecialNotFile(value)}}