pub struct SensorManager {
pub accelerometer: Option<SensorReading>,
pub gyroscope: Option<SensorReading>,
pub magnetometer: Option<SensorReading>,
pub pending_event: 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.
Implementations§
Source§impl SensorManager
impl SensorManager
pub fn new() -> Self
Sourcepub fn reading(&self, kind: SensorKind) -> Option<SensorReading>
pub 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 fn clear_pending_event(&mut self)
pub 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).
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 moreSource§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
Source§fn eq(&self, other: &SensorManager) -> bool
fn eq(&self, other: &SensorManager) -> bool
self and other values to be equal, and is used by ==.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