qubit_http/options/proxy_type.rs
1/*******************************************************************************
2 *
3 * Copyright (c) 2025 - 2026.
4 * Haixing Hu, Qubit Co. Ltd.
5 *
6 * All rights reserved.
7 *
8 ******************************************************************************/
9
10/// URL scheme selector used when constructing the proxy URL for reqwest.
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
12pub enum ProxyType {
13 /// HTTP proxy.
14 #[default]
15 Http,
16 /// HTTPS proxy.
17 Https,
18 /// SOCKS5 proxy.
19 Socks5,
20}
21
22impl ProxyType {
23 /// Returns the URL scheme string embedded in `proxy_url` for reqwest.
24 ///
25 /// # Parameters
26 /// - `self`: Proxy kind.
27 ///
28 /// # Returns
29 /// `"http"`, `"https"`, or `"socks5h"` (SOCKS5 with remote DNS).
30 pub fn scheme(self) -> &'static str {
31 match self {
32 ProxyType::Http => "http",
33 ProxyType::Https => "https",
34 ProxyType::Socks5 => "socks5h",
35 }
36 }
37}