#[non_exhaustive]pub enum EnvPrecedence {
BeforeSystem,
AfterSystem,
}Expand description
Where the process environment ranks against the OS settings in
ProxyConfig::with_env.
A third ranking, “ignore the environment”, is not a variant: a caller who wants the
environment ignored does not call with_env.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
BeforeSystem
The environment outranks every OS source. What a consumer layering a *_proxy
reader over the system settings gets by default: Go’s golang.org/x/net/http/ httpproxy reads the variables and nothing else, so a caller who consults it first
has already chosen this.
AfterSystem
The OS settings outrank the environment, which answers only when they produced no
configuration at all. Not per scheme: one OS source is enough to settle every
scheme, including the ones it says nothing about; ProxyConfig::with_env ranks
sources, it does not fill slots. Chromium’s
net/proxy_resolution/proxy_config_service_linux.cc does this in the strong form:
once the desktop settings have produced a configuration it never looks at the
variables, a desktop mode of “none” counts as one, and reading mode always finds a
value, so a stock desktop with no proxy configured still counts.
This crate is a shade weaker on GNOME: it asks who wrote that mode, and only one
that was set (in the user’s dconf layer, or an administrator’s profile) becomes a
source. A machine whose proxy settings were never touched therefore reaches this
rank with an empty sources, and the environment answers. An unset mode and a
mode set to direct are different answers, and only the second should outrank a
*_proxy an operator set.
On Windows that leaves this a rank the environment never takes: read always
reports a Registry source, ProxyEnable = 0 included, so there is never a
snapshot for the environment to answer for. macOS is nearly as closed: a scope the
reader could interpret becomes a source whatever it says,
Direct included, so the environment answers only where
neither State: nor Setup: came back (a missing key, a NULL, or a value that is
not a dictionary); scopes that name no proxy do not qualify. Linux is where this
rank applies: desktop stores that exist and are unset produce a snapshot with no
source at all. So does the degraded case beside it (the store this session’s desktop
would normally use compiled out of the build while the other one is unset), where
the empty sources means “never consulted” rather than “found nothing”, which only
fallbacks records.
A machine with no desktop store at all is not this case: read fails with
Error::Unsupported, so there is no snapshot to fold an
environment into.
Even a rank the environment never takes differs from the “ignore” this enum leaves
out, which is a caller not folding at all: a rank settles only effective, and the
rest of the fold happens either way, so the environment lands in
sources and captured_at drops
to the older of the two reads even where this one can never win.