Skip to main content

NetEventObserver

Struct NetEventObserver 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn backend(&self) -> &'static str

Backend identifier (for diagnostics).

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.