pub struct GenericProxyConfig {
pub http_url: Option<String>,
pub https_url: Option<String>,
}
Expand description
§GenericProxyConfig
A generic proxy configuration for standard HTTP/HTTPS proxies.
This configuration allows you to specify separate proxies for HTTP and HTTPS requests, or use the same proxy for both. It’s suitable for most standard proxy services.
§Features
- Support for separate HTTP and HTTPS proxies
- Simple configuration with minimal required fields
- Compatible with most proxy services
§Example Usage
// Create a proxy configuration with the same proxy for both HTTP and HTTPS
let proxy = GenericProxyConfig::new(
Some("http://username:password@proxy.example.com:8080".to_string()),
None
)?;
// Use it with the YouTube Transcript API
let api = YouTubeTranscriptApi::new(
None,
Some(Box::new(proxy)),
None
)?;
Fields§
§http_url: Option<String>
URL for HTTP proxy (format: “http://[username:password@]host:port”)
https_url: Option<String>
URL for HTTPS proxy (format: “https://[username:password@]host:port”)
Implementations§
Source§impl GenericProxyConfig
impl GenericProxyConfig
Sourcepub fn new(
http_url: Option<String>,
https_url: Option<String>,
) -> Result<Self, InvalidProxyConfig>
pub fn new( http_url: Option<String>, https_url: Option<String>, ) -> Result<Self, InvalidProxyConfig>
Creates a new generic proxy configuration.
You can specify different proxies for HTTP and HTTPS requests, or use the same proxy for both by specifying only one. At least one of the proxy URLs must be provided.
§Parameters
http_url
- Optional URL for HTTP proxyhttps_url
- Optional URL for HTTPS proxy
§Returns
Result<Self, InvalidProxyConfig>
- A new proxy configuration or an error
§Errors
Returns InvalidProxyConfig
if both http_url
and https_url
are None
.
§Example
// Configure different proxies for HTTP and HTTPS
let proxy = GenericProxyConfig::new(
Some("http://user:pass@proxy1.example.com:8080".to_string()),
Some("http://user:pass@proxy2.example.com:8443".to_string())
)?;
Trait Implementations§
Source§impl Clone for GenericProxyConfig
impl Clone for GenericProxyConfig
Source§fn clone(&self) -> GenericProxyConfig
fn clone(&self) -> GenericProxyConfig
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for GenericProxyConfig
impl Debug for GenericProxyConfig
Source§impl ProxyConfig for GenericProxyConfig
impl ProxyConfig for GenericProxyConfig
Source§fn to_requests_dict(&self) -> HashMap<String, String>
fn to_requests_dict(&self) -> HashMap<String, String>
Converts the generic proxy configuration to a reqwest-compatible dictionary.
If either HTTP or HTTPS URL is missing, the other is used as a fallback.
§Returns
HashMap<String, String>
- Map with “http” and “https” keys and their proxy URLs