pub struct ProxyRule {
pub scope: ProxyScope,
pub url: String,
pub auth: Option<ProxyAuth>,
pub no_proxy: Option<String>,
}Expand description
One proxy: where it lives, which requests go through it, and which hosts bypass it.
Fields§
§scope: ProxyScopeWhich request URLs this rule applies to.
url: StringThe proxy’s own URL, e.g. http://proxy.corp:8080. http and https proxies are always
supported; socks4, socks5, and socks5h need the crate’s socks feature. An
unparseable or unsupported URL is reported by
Fetcher::new.
auth: Option<ProxyAuth>Credentials for the proxy, if it demands any.
no_proxy: Option<String>Hosts that bypass this proxy, in NO_PROXY syntax: comma-separated entries, each a
domain (matching that domain and its subdomains), an IP address, a CIDR block, or * for
everything. None sends every in-scope request through the proxy — note that this does
not fall back to the NO_PROXY environment variable, since configuring a rule
programmatically opts out of the environment entirely.
Implementations§
Source§impl ProxyRule
impl ProxyRule
Sourcepub fn all(url: impl Into<String>) -> Self
pub fn all(url: impl Into<String>) -> Self
A rule routing every request through url, whatever the scheme.
Sourcepub fn new(scope: ProxyScope, url: impl Into<String>) -> Self
pub fn new(scope: ProxyScope, url: impl Into<String>) -> Self
A rule with an explicit scope, no credentials, and no bypass list.
Sourcepub fn with_basic_auth(
self,
username: impl Into<String>,
password: impl Into<String>,
) -> Self
pub fn with_basic_auth( self, username: impl Into<String>, password: impl Into<String>, ) -> Self
Present username / password to the proxy via Proxy-Authorization: Basic.
Sourcepub fn with_custom_auth(self, header_value: impl Into<String>) -> Self
pub fn with_custom_auth(self, header_value: impl Into<String>) -> Self
Present a verbatim Proxy-Authorization header value, e.g. "Bearer <token>".
Sourcepub fn bypassing(self, no_proxy: impl Into<String>) -> Self
pub fn bypassing(self, no_proxy: impl Into<String>) -> Self
Exempt hosts from this proxy, in NO_PROXY syntax — see ProxyRule::no_proxy.
Trait Implementations§
impl Eq for ProxyRule
impl StructuralPartialEq for ProxyRule
Auto Trait Implementations§
impl Freeze for ProxyRule
impl RefUnwindSafe for ProxyRule
impl Send for ProxyRule
impl Sync for ProxyRule
impl Unpin for ProxyRule
impl UnsafeUnpin for ProxyRule
impl UnwindSafe for ProxyRule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.