pub struct WindowMetricsPublisher { /* private fields */ }Expand description
Per-shell-instance change detector over the window’s WindowMetrics: each
of the three shells owns one and drives it from its own resize/insets entry
points, publishing only what it reports as changed.
§Why this is not a per-frame push
Delivering WindowMetrics to app code means provide_context-ing it under
the reactive root owner, exactly as Theme and WindowInsets already are
— a plain map insert that notifies nothing and creates no subscription, so
re-providing does not itself wake a frame. The guard here exists for cost
at the FFI boundary instead: a shell that re-provided metrics
unconditionally once per frame would pay a lock write plus an allocation
every frame for no observable benefit, since the next rebuild (already
driven by the resize or inset change itself) is what actually picks the
new value up. This type makes the guarded path the only path:
poll returns Some only on an actual change, mirroring
ThemeOverrideWatcher’s poll-returns-Option
shape and RenderRoot::set_insets’s PartialEq-guarded no-op.
It is deliberately reactive-free (this crate ships no reactive dependency —
see docs/ARCHITECTURE.md’s Layer Dependencies): it decides whether to
publish and computes what to publish, and each shell owns the
provide_context call itself. That keeps the unit conversion and the
change-detection host-testable even though both mobile app modules are
target-gated and never host-compiled.
Implementations§
Source§impl WindowMetricsPublisher
impl WindowMetricsPublisher
Sourcepub fn poll(
&mut self,
physical: (u32, u32),
scale: f64,
insets: WindowInsets,
) -> Option<WindowMetrics>
pub fn poll( &mut self, physical: (u32, u32), scale: f64, insets: WindowInsets, ) -> Option<WindowMetrics>
Assemble the current WindowMetrics (see window_metrics for the
unit contract) and return it only if it differs from the last one
this publisher reported; None means the shell must not re-provide.
A shell calls this from every point where one of the inputs actually moves — surface create/resize and the insets callback — never from its per-frame driver, which only reads values these entry points already stored.
Sourcepub fn last(&self) -> Option<WindowMetrics>
pub fn last(&self) -> Option<WindowMetrics>
The metrics last published, or None before the first change-reporting
poll.