#[non_exhaustive]pub struct WatchOptions {
pub debounce: Duration,
pub watch_group_policy: bool,
pub poll_interval: Option<Duration>,
}Expand description
Tuning knobs for ProxyWatcher::with_options (#[non_exhaustive]: use
WatchOptions::new / with_*).
use proxy_watch::WatchOptions;
use std::time::Duration;
let opts = WatchOptions::new()
.with_debounce(Duration::from_millis(50))
.with_group_policy(false);
assert_eq!(opts.debounce, Duration::from_millis(50));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.debounce: DurationDebounce before re-read (default DEFAULT_DEBOUNCE); anything over 24 h is
lowered to it.
A fixed window, not a sliding one: it opens on the first change, and further changes inside it are folded into the same emission rather than pushing it back. The wait after a change is therefore bounded by this value however long the storm of changes behind it lasts.
watch_group_policy: boolAlso read and watch per-machine group policy (default true; Windows only).
No failure of this source can fail a read (the machine’s WinHTTP default is the
other source with that property). Whatever goes wrong here (an HKLM key this process
cannot read, a policy AutoConfigURL this crate refuses as malformed) is reported
as no policy, and ProxyConfig::fallbacks records that something went wrong
without saying what. A ProxyConfigSource::GroupPolicy entry is never
effective (see that variant for the measurement), so
failing the whole read on its account would refuse a machine whose per-user store
answers well. A value stored under a type the key’s own name does not carry is not a
failure at all: a ProxyEnable written as a REG_SZ rather than the documented
REG_DWORD reads like one that was never written, and the policy is reported as
absent.
The key is watched because it holds one value Windows does act on
(ProxySettingsPerUser, the only one inetres.admx defines there) and switching it
changes what WinHttpGetIEProxyConfigForCurrentUser returns, so a change under this
key can change the effective configuration even though nothing under it is ever the
effective configuration.
poll_interval: Option<Duration>Timer re-read in addition to notifications. Anything under 200 ms is raised to
200 ms. A long interval is shortened so that the wait it becomes is finite, by a
ceiling that differs per platform: 24 h on Linux, Android and iOS, an hour on macOS,
and on Windows the longest wait the OS call accepts, u32::MAX - 1 ms (about 49
days).
It also decides how a notification route that will not arm reaches the caller. With
no interval set, the platform’s primary route failing to arm is fatal:
ProxyWatcher::with_options returns Error::Io, naming this option as the fix.
With one set, that same failure only reaches WatchHealth::degraded, on a watcher
that starts. Every other route degrades either way.
Implementations§
Source§impl WatchOptions
impl WatchOptions
Sourcepub const fn with_debounce(self, debounce: Duration) -> Self
pub const fn with_debounce(self, debounce: Duration) -> Self
Set the debounce window (builder style).
Sourcepub const fn with_group_policy(self, watch: bool) -> Self
pub const fn with_group_policy(self, watch: bool) -> Self
Enable or disable reading and watching per-machine group policy (builder style).
Sourcepub const fn with_poll_interval(self, interval: Option<Duration>) -> Self
pub const fn with_poll_interval(self, interval: Option<Duration>) -> Self
Set or clear the polling interval (see WatchOptions::poll_interval).
use proxy_watch::WatchOptions;
use std::time::Duration;
let opts = WatchOptions::new().with_poll_interval(Some(Duration::from_secs(30)));
assert_eq!(opts.poll_interval, Some(Duration::from_secs(30)));