#[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).
The one source no failure of which can fail a read. 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. That is affordable because 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 perfectly 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 here exactly like one that was never written, and the
policy is reported as absent.
Watching it is worth more than reading it. The key 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 it, and on macOS anything over an hour is lowered to an hour — the run loop wait this becomes is bounded so that it is never literally infinite.
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)));Trait Implementations§
Source§impl Clone for WatchOptions
impl Clone for WatchOptions
Source§fn clone(&self) -> WatchOptions
fn clone(&self) -> WatchOptions
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 WatchOptions
impl Debug for WatchOptions
Source§impl Default for WatchOptions
impl Default for WatchOptions
impl Eq for WatchOptions
Source§impl PartialEq for WatchOptions
impl PartialEq for WatchOptions
impl StructuralPartialEq for WatchOptions
Auto Trait Implementations§
impl Freeze for WatchOptions
impl RefUnwindSafe for WatchOptions
impl Send for WatchOptions
impl Sync for WatchOptions
impl Unpin for WatchOptions
impl UnsafeUnpin for WatchOptions
impl UnwindSafe for WatchOptions
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<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.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
impl<T> ErasedDestructor for Twhere
T: 'static,
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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.