use parse_display::FromStr as DeriveFromStr;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, DeriveFromStr)]
#[serde(rename_all = "snake_case")]
#[display(style = "snake_case")]
pub enum ProxyType {
#[default]
#[display("http")]
#[from_str(regex = "(?i)http")]
Http,
#[display("https")]
#[from_str(regex = "(?i)https")]
Https,
#[display("socks5h")]
#[from_str(regex = "(?i)socks5h|socks5")]
Socks5,
}
impl ProxyType {
pub fn scheme(self) -> &'static str {
match self {
ProxyType::Http => "http",
ProxyType::Https => "https",
ProxyType::Socks5 => "socks5h",
}
}
}