pub struct NetEventObserver { /* private fields */ }Expand description
A running path-event observer. Construct one with start;
the OS watcher runs until the observer is dropped, which stops the thread
(Linux / BSD) or cancels the change callbacks (Windows).
Implementations§
Source§impl NetEventObserver
impl NetEventObserver
Sourcepub fn start(iface: Option<String>) -> Self
pub fn start(iface: Option<String>) -> Self
Start watching for path events. iface names the interface to read the
MTU from; None auto-detects the first non-loopback up interface (the
usual single-uplink case). Watcher startup is best-effort: if the OS
notification source cannot be opened the observer still constructs and
simply never fires, so a caller need not handle a failure.
Sourcepub fn path_shift(&self) -> f32
pub fn path_shift(&self) -> f32
Decaying path-shift signal (0..=1): high just after a route / carrier /
MTU event, fading with a fixed half-life. Fused as a path_shift source.
Sourcepub fn pmtu(&self) -> Option<u16>
pub fn pmtu(&self) -> Option<u16>
Current egress-interface MTU in bytes, or None if unknown / the
platform does not read it. Reported to the peer in a PmtuFrame.
Sourcepub fn event_count(&self) -> u64
pub fn event_count(&self) -> u64
Total path events observed since start (monotonic). A nonzero value is the durable proof the watcher fired, independent of the shift decay.
Sourcepub fn inject_event(&self)
pub fn inject_event(&self)
Synthetically record a path event, as if the OS had announced a route /
carrier change. Drives the --sim-path-event demo and the unit tests on
a host where flapping a real interface is impractical; the production
path is the OS watcher.
Sourcepub fn inject_pmtu(&self, mtu: u16)
pub fn inject_pmtu(&self, mtu: u16)
Synthetically report a path MTU, recording an event if it is a drop - the same path a polled MTU decrease would take. For tests / demos.