pub struct SystemProxyConfig { /* private fields */ }std only.Expand description
A snapshot of the operating system’s proxy configuration.
HTTP and HTTPS identify the destination scheme, not necessarily the transport protocol used to reach the proxy. A SOCKS5 proxy is used as a fallback when no scheme-specific proxy is configured. A PAC URI takes precedence over fixed proxies because it can make a per-request decision; each platform reader records whether its bypass entries apply before PAC. System proxy routing always bypasses loopback hosts, including before PAC evaluation, matching native proxy stacks.
Implementations§
Source§impl SystemProxyConfig
impl SystemProxyConfig
Sourcepub async fn try_from_system() -> Result<Self, BoxError>
pub async fn try_from_system() -> Result<Self, BoxError>
Read the current platform proxy snapshot.
- Windows uses the active user’s WinINET/Internet Options settings;
- macOS and iOS use CFNetwork’s system proxy dictionary;
- Android uses
ConnectivityManager.getDefaultProxy(), with the legacyProxyAPI on Android versions before API 23; - Linux and BSD prefer KDE’s
kioslavercon KDE desktops, otherwise reading GNOMEgsettingsbefore falling back to KDE.
This deliberately does not inspect http_proxy or related environment
variables. Those are application configuration and are handled by
ProxyEnvLayer and
NoProxyEnvLayer instead.
Automatic discovery such as WPAD is recorded by Self::auto_detect
but is not attempted when the platform does not provide a concrete PAC
URI. Malformed non-empty proxy values are reported as errors rather
than silently bypassing a configured system policy.
Platform operations that have asynchronous APIs are awaited directly. Native platforms that only expose a synchronous snapshot call keep that call narrowly isolated inside their platform reader.
Sourcepub async fn try_from_system_with_invalid_bypass_rule_policy(
policy: SystemProxyInvalidBypassRulePolicy,
) -> Result<Self, BoxError>
pub async fn try_from_system_with_invalid_bypass_rule_policy( policy: SystemProxyInvalidBypassRulePolicy, ) -> Result<Self, BoxError>
Read the current platform proxy snapshot with an explicit invalid bypass-rule policy.
Ignore is the default
used by Self::try_from_system. Selecting
Reject returns an error
instead of accepting a snapshot with one or more discarded rules.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Return whether this snapshot contains no automatic, PAC, or fixed proxy settings.
Sourcepub const fn http_proxy(&self) -> Option<&ProxyAddress>
pub const fn http_proxy(&self) -> Option<&ProxyAddress>
The proxy for HTTP destinations.
Sourcepub const fn https_proxy(&self) -> Option<&ProxyAddress>
pub const fn https_proxy(&self) -> Option<&ProxyAddress>
The proxy for HTTPS destinations.
Sourcepub const fn socks5_proxy(&self) -> Option<&ProxyAddress>
pub const fn socks5_proxy(&self) -> Option<&ProxyAddress>
The SOCKS5 fallback proxy.
Sourcepub const fn auto_detect(&self) -> bool
pub const fn auto_detect(&self) -> bool
Whether the platform requested automatic proxy discovery (for example, WPAD) without necessarily supplying a concrete PAC URI.
Sourcepub const fn exclude_simple_hostnames(&self) -> bool
pub const fn exclude_simple_hostnames(&self) -> bool
Whether names without a dot bypass fixed proxies.
Sourcepub const fn reversed_bypass(&self) -> bool
pub const fn reversed_bypass(&self) -> bool
Whether fixed proxies are used only for hosts matching bypass.
KDE exposes this uncommon inverted exception-list mode. The default is
false, where matching hosts bypass the proxy in the usual way.
Sourcepub fn maybe_with_http_proxy(self, proxy: Option<ProxyAddress>) -> Self
pub fn maybe_with_http_proxy(self, proxy: Option<ProxyAddress>) -> Self
Set the proxy used for HTTP destinations.
Sourcepub fn maybe_set_http_proxy(&mut self, proxy: Option<ProxyAddress>) -> &mut Self
pub fn maybe_set_http_proxy(&mut self, proxy: Option<ProxyAddress>) -> &mut Self
Set the proxy used for HTTP destinations.
Sourcepub fn with_http_proxy(self, proxy: ProxyAddress) -> Self
pub fn with_http_proxy(self, proxy: ProxyAddress) -> Self
Set the proxy used for HTTP destinations.
Sourcepub fn set_http_proxy(&mut self, proxy: ProxyAddress) -> &mut Self
pub fn set_http_proxy(&mut self, proxy: ProxyAddress) -> &mut Self
Set the proxy used for HTTP destinations.
Sourcepub fn without_http_proxy(self) -> Self
pub fn without_http_proxy(self) -> Self
Set the proxy used for HTTP destinations.
Sourcepub fn unset_http_proxy(&mut self) -> &mut Self
pub fn unset_http_proxy(&mut self) -> &mut Self
Set the proxy used for HTTP destinations.
Sourcepub fn maybe_with_https_proxy(self, proxy: Option<ProxyAddress>) -> Self
pub fn maybe_with_https_proxy(self, proxy: Option<ProxyAddress>) -> Self
Set the proxy used for HTTPS destinations.
Sourcepub fn maybe_set_https_proxy(
&mut self,
proxy: Option<ProxyAddress>,
) -> &mut Self
pub fn maybe_set_https_proxy( &mut self, proxy: Option<ProxyAddress>, ) -> &mut Self
Set the proxy used for HTTPS destinations.
Sourcepub fn with_https_proxy(self, proxy: ProxyAddress) -> Self
pub fn with_https_proxy(self, proxy: ProxyAddress) -> Self
Set the proxy used for HTTPS destinations.
Sourcepub fn set_https_proxy(&mut self, proxy: ProxyAddress) -> &mut Self
pub fn set_https_proxy(&mut self, proxy: ProxyAddress) -> &mut Self
Set the proxy used for HTTPS destinations.
Sourcepub fn without_https_proxy(self) -> Self
pub fn without_https_proxy(self) -> Self
Set the proxy used for HTTPS destinations.
Sourcepub fn unset_https_proxy(&mut self) -> &mut Self
pub fn unset_https_proxy(&mut self) -> &mut Self
Set the proxy used for HTTPS destinations.
Sourcepub fn maybe_with_socks5_proxy(self, proxy: Option<ProxyAddress>) -> Self
pub fn maybe_with_socks5_proxy(self, proxy: Option<ProxyAddress>) -> Self
Set the SOCKS5 fallback proxy.
Sourcepub fn maybe_set_socks5_proxy(
&mut self,
proxy: Option<ProxyAddress>,
) -> &mut Self
pub fn maybe_set_socks5_proxy( &mut self, proxy: Option<ProxyAddress>, ) -> &mut Self
Set the SOCKS5 fallback proxy.
Sourcepub fn with_socks5_proxy(self, proxy: ProxyAddress) -> Self
pub fn with_socks5_proxy(self, proxy: ProxyAddress) -> Self
Set the SOCKS5 fallback proxy.
Sourcepub fn set_socks5_proxy(&mut self, proxy: ProxyAddress) -> &mut Self
pub fn set_socks5_proxy(&mut self, proxy: ProxyAddress) -> &mut Self
Set the SOCKS5 fallback proxy.
Sourcepub fn without_socks5_proxy(self) -> Self
pub fn without_socks5_proxy(self) -> Self
Set the SOCKS5 fallback proxy.
Sourcepub fn unset_socks5_proxy(&mut self) -> &mut Self
pub fn unset_socks5_proxy(&mut self) -> &mut Self
Set the SOCKS5 fallback proxy.
Sourcepub fn maybe_with_pac_uri(self, pac_uri: Option<Uri>) -> Self
pub fn maybe_with_pac_uri(self, pac_uri: Option<Uri>) -> Self
Set the PAC script URI.
Sourcepub fn maybe_set_pac_uri(&mut self, pac_uri: Option<Uri>) -> &mut Self
pub fn maybe_set_pac_uri(&mut self, pac_uri: Option<Uri>) -> &mut Self
Set the PAC script URI.
Sourcepub fn with_pac_uri(self, pac_uri: Uri) -> Self
pub fn with_pac_uri(self, pac_uri: Uri) -> Self
Set the PAC script URI.
Sourcepub fn set_pac_uri(&mut self, pac_uri: Uri) -> &mut Self
pub fn set_pac_uri(&mut self, pac_uri: Uri) -> &mut Self
Set the PAC script URI.
Sourcepub fn without_pac_uri(self) -> Self
pub fn without_pac_uri(self) -> Self
Set the PAC script URI.
Sourcepub fn unset_pac_uri(&mut self) -> &mut Self
pub fn unset_pac_uri(&mut self) -> &mut Self
Set the PAC script URI.
Sourcepub fn with_auto_detect(self, auto_detect: bool) -> Self
pub fn with_auto_detect(self, auto_detect: bool) -> Self
Record whether automatic proxy discovery is enabled.
Rama exposes this signal but does not perform WPAD itself.
Sourcepub fn set_auto_detect(&mut self, auto_detect: bool) -> &mut Self
pub fn set_auto_detect(&mut self, auto_detect: bool) -> &mut Self
Record whether automatic proxy discovery is enabled.
Rama exposes this signal but does not perform WPAD itself.
Sourcepub fn with_bypass(
self,
bypass: impl IntoIterator<Item = impl Into<Box<str>>>,
) -> Self
pub fn with_bypass( self, bypass: impl IntoIterator<Item = impl Into<Box<str>>>, ) -> Self
Replace the fixed-proxy bypass patterns, ignoring invalid entries.
Use Self::try_set_bypass with
Reject when an invalid
entry should reject the complete update. Boxed strings transfer
directly into snapshot storage; borrowed strings are copied because
the snapshot owns its rules.
Sourcepub fn set_bypass(
&mut self,
bypass: impl IntoIterator<Item = impl Into<Box<str>>>,
) -> &mut Self
pub fn set_bypass( &mut self, bypass: impl IntoIterator<Item = impl Into<Box<str>>>, ) -> &mut Self
Replace the fixed-proxy bypass patterns, ignoring invalid entries.
Use Self::try_set_bypass with
Reject when an invalid
entry should reject the complete update. Boxed strings transfer
directly into snapshot storage; borrowed strings are copied because
the snapshot owns its rules.
Sourcepub fn try_with_bypass(
self,
bypass: impl IntoIterator<Item = impl Into<Box<str>>>,
policy: SystemProxyInvalidBypassRulePolicy,
) -> Result<Self, BoxError>
pub fn try_with_bypass( self, bypass: impl IntoIterator<Item = impl Into<Box<str>>>, policy: SystemProxyInvalidBypassRulePolicy, ) -> Result<Self, BoxError>
Replace the fixed-proxy bypass patterns using an explicit invalid-rule policy.
The update is atomic: when Reject
encounters an invalid rule, this returns an error and leaves the prior
bypass list unchanged. Boxed strings transfer directly into snapshot
storage; borrowed strings are copied because the snapshot owns its
rules.
Sourcepub fn try_set_bypass(
&mut self,
bypass: impl IntoIterator<Item = impl Into<Box<str>>>,
policy: SystemProxyInvalidBypassRulePolicy,
) -> Result<&mut Self, BoxError>
pub fn try_set_bypass( &mut self, bypass: impl IntoIterator<Item = impl Into<Box<str>>>, policy: SystemProxyInvalidBypassRulePolicy, ) -> Result<&mut Self, BoxError>
Replace the fixed-proxy bypass patterns using an explicit invalid-rule policy.
The update is atomic: when Reject
encounters an invalid rule, this returns an error and leaves the prior
bypass list unchanged. Boxed strings transfer directly into snapshot
storage; borrowed strings are copied because the snapshot owns its
rules.
Sourcepub fn with_exclude_simple_hostnames(self, exclude: bool) -> Self
pub fn with_exclude_simple_hostnames(self, exclude: bool) -> Self
Configure whether names without a dot bypass fixed proxies.
Sourcepub fn set_exclude_simple_hostnames(&mut self, exclude: bool) -> &mut Self
pub fn set_exclude_simple_hostnames(&mut self, exclude: bool) -> &mut Self
Configure whether names without a dot bypass fixed proxies.
Sourcepub fn with_reversed_bypass(self, reversed: bool) -> Self
pub fn with_reversed_bypass(self, reversed: bool) -> Self
Invert the meaning of fixed-proxy bypass patterns.
Sourcepub fn set_reversed_bypass(&mut self, reversed: bool) -> &mut Self
pub fn set_reversed_bypass(&mut self, reversed: bool) -> &mut Self
Invert the meaning of fixed-proxy bypass patterns.
Trait Implementations§
Source§impl Clone for SystemProxyConfig
impl Clone for SystemProxyConfig
Source§fn clone(&self) -> SystemProxyConfig
fn clone(&self) -> SystemProxyConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SystemProxyConfig
impl Debug for SystemProxyConfig
Source§impl Default for SystemProxyConfig
impl Default for SystemProxyConfig
Source§fn default() -> SystemProxyConfig
fn default() -> SystemProxyConfig
Auto Trait Implementations§
impl !Freeze for SystemProxyConfig
impl RefUnwindSafe for SystemProxyConfig
impl Send for SystemProxyConfig
impl Sync for SystemProxyConfig
impl Unpin for SystemProxyConfig
impl UnsafeUnpin for SystemProxyConfig
impl UnwindSafe for SystemProxyConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
Source§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<V, F> ValueFormatter<&V> for F
impl<V, F> ValueFormatter<&V> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &&V)
fn format_value(writer: impl ValueWriter, value: &&V)
value to writerSource§impl<V, F> ValueFormatter<Arc<V>> for F
impl<V, F> ValueFormatter<Arc<V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Arc<V>)
fn format_value(writer: impl ValueWriter, value: &Arc<V>)
value to writerSource§impl<V, F> ValueFormatter<Box<V>> for F
impl<V, F> ValueFormatter<Box<V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Box<V>)
fn format_value(writer: impl ValueWriter, value: &Box<V>)
value to writerSource§impl<V, F> ValueFormatter<Cow<'_, V>> for F
impl<V, F> ValueFormatter<Cow<'_, V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
value to writerSource§impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Option<V>)
fn format_value(writer: impl ValueWriter, value: &Option<V>)
value to writer