Skip to main content

WindowMetricsPublisher

Struct WindowMetricsPublisher 

Source
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

Source

pub fn new() -> Self

A fresh publisher that has published nothing yet.

Source

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.

Source

pub fn last(&self) -> Option<WindowMetrics>

The metrics last published, or None before the first change-reporting poll.

Trait Implementations§

Source§

impl Debug for WindowMetricsPublisher

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WindowMetricsPublisher

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> ErasedDestructor for T
where T: 'static,

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> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.