pub struct SensorManager {
pub accelerometer: Option<SensorReading>,
pub gyroscope: Option<SensorReading>,
pub magnetometer: Option<SensorReading>,
pub pending_event: bool,
pub has_listeners: bool,
}Expand description
Cross-platform sensor state. One per App — the OS exposes a single
per-process sensor subscription, not per-window.
Fields§
§accelerometer: Option<SensorReading>Latest accelerometer reading (m/s²), or None until a sample arrives.
gyroscope: Option<SensorReading>Latest gyroscope reading (rad/s).
magnetometer: Option<SensorReading>Latest magnetometer reading (µT).
pending_event: booltrue when a reading advanced since the last event-pass drain. Set by
set_reading, read by the EventProvider impl,
cleared by clear_pending_event.
has_listeners: booltrue while any node in the current layout registers a
SensorChanged callback (Hover or Window filter). Recomputed on every
relayout by the DOM walk in shell2::common::layout; the capability
pump polls the platform sensor backend only while this is set
(MWA-A1 arming signal — no listeners, no polling, no timer).
Implementations§
Source§impl SensorManager
impl SensorManager
pub fn new() -> Self
Sourcepub const fn reading(&self, kind: SensorKind) -> Option<SensorReading>
pub const fn reading(&self, kind: SensorKind) -> Option<SensorReading>
Latest reading for kind, or None if no backend has delivered one.
Sourcepub fn set_reading(&mut self, reading: SensorReading) -> bool
pub fn set_reading(&mut self, reading: SensorReading) -> bool
Apply a reading the backend delivered. Returns true if it advanced
(bit-pattern different from the previous, so missing-as-NaN axes
don’t make every sample look “changed”).
Sourcepub const fn clear_pending_event(&mut self)
pub const fn clear_pending_event(&mut self)
Clear the pending-event flag. The dll calls this after the event pass
has collected the SensorChanged event (mirrors clear_changeset).
Sourcepub const fn set_has_listeners(&mut self, has: bool)
pub const fn set_has_listeners(&mut self, has: bool)
Relayout walk reports whether any node listens for SensorChanged.
Sourcepub const fn has_listeners(&self) -> bool
pub const fn has_listeners(&self) -> bool
true while the capability pump should poll the sensor backend.
Trait Implementations§
Source§impl Clone for SensorManager
impl Clone for SensorManager
Source§fn clone(&self) -> SensorManager
fn clone(&self) -> SensorManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SensorManager
Source§impl Debug for SensorManager
impl Debug for SensorManager
Source§impl Default for SensorManager
impl Default for SensorManager
Source§fn default() -> SensorManager
fn default() -> SensorManager
Source§impl EventProvider for SensorManager
impl EventProvider for SensorManager
Source§fn get_pending_events(&self, timestamp: Instant) -> Vec<SyntheticEvent>
fn get_pending_events(&self, timestamp: Instant) -> Vec<SyntheticEvent>
Yield a window-level SensorChanged event when a reading advanced
since the last drain (target = root; read the value via
CallbackInfo::get_sensor_reading inside the callback).
Source§impl PartialEq for SensorManager
impl PartialEq for SensorManager
impl StructuralPartialEq for SensorManager
Auto Trait Implementations§
impl Freeze for SensorManager
impl RefUnwindSafe for SensorManager
impl Send for SensorManager
impl Sync for SensorManager
impl Unpin for SensorManager
impl UnsafeUnpin for SensorManager
impl UnwindSafe for SensorManager
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more