#[non_exhaustive]pub struct EventMeta { /* private fields */ }Expand description
Provider-neutral metadata attached to one routed event.
The metadata correlates one host-local ID and monotonic timestamp with a logical window and native presentation generation. Optional pointer data is explicit and is not inferred from the event variant. The struct is non-exhaustive and its fields remain constructor/accessor controlled.
§Examples
use std::time::Duration;
use ailloli_ui_runtime::{app::PresentationGeneration, input::{EventId, EventMeta, EventTimestamp}};
let meta = EventMeta::new(EventId::new(1), EventTimestamp::new(Duration::from_millis(5)), "main", PresentationGeneration::new(2));
assert_eq!(meta.id().get(), 1);
assert_eq!(meta.logical_window_id().as_str(), "main");
assert_eq!(meta.pointer(), None);Implementations§
Source§impl EventMeta
Provides the operations defined for EventMeta.
impl EventMeta
Provides the operations defined for EventMeta.
Sourcepub fn new(
id: EventId,
timestamp: EventTimestamp,
logical_window_id: impl Into<LogicalWindowId>,
presentation_generation: PresentationGeneration,
) -> Self
pub fn new( id: EventId, timestamp: EventTimestamp, logical_window_id: impl Into<LogicalWindowId>, presentation_generation: PresentationGeneration, ) -> Self
Creates metadata without a pointer sample.
IDs, timestamp order, logical-window existence, and presentation liveness
are not validated here. Attach pointer data with Self::with_pointer.
§Examples
use std::time::Duration;
use ailloli_ui_runtime::{app::PresentationGeneration, input::{EventId, EventMeta, EventTimestamp}};
let meta = EventMeta::new(EventId::new(9), EventTimestamp::new(Duration::ZERO), "editor", PresentationGeneration::INITIAL);
assert_eq!(meta.id(), EventId::new(9));
assert!(meta.pointer().is_none());Sourcepub const fn id(&self) -> EventId
pub const fn id(&self) -> EventId
Returns the host-local event identifier.
§Examples
use std::time::Duration;
use ailloli_ui_runtime::{app::PresentationGeneration, input::{EventId, EventMeta, EventTimestamp}};
let meta = EventMeta::new(EventId::new(3), EventTimestamp::new(Duration::ZERO), "main", PresentationGeneration::INITIAL);
assert_eq!(meta.id().get(), 3);Sourcepub const fn timestamp(&self) -> EventTimestamp
pub const fn timestamp(&self) -> EventTimestamp
Returns the duration since the host-defined origin.
§Examples
use std::time::Duration;
use ailloli_ui_runtime::{app::PresentationGeneration, input::{EventId, EventMeta, EventTimestamp}};
let timestamp = EventTimestamp::new(Duration::from_millis(12));
let meta = EventMeta::new(EventId::new(1), timestamp, "main", PresentationGeneration::INITIAL);
assert_eq!(meta.timestamp(), timestamp);Sourcepub fn logical_window_id(&self) -> &LogicalWindowId
pub fn logical_window_id(&self) -> &LogicalWindowId
Borrows the exact logical-window identity supplied at construction.
§Examples
use std::time::Duration;
use ailloli_ui_runtime::{app::PresentationGeneration, input::{EventId, EventMeta, EventTimestamp}};
let meta = EventMeta::new(EventId::new(1), EventTimestamp::new(Duration::ZERO), "main", PresentationGeneration::INITIAL);
assert_eq!(meta.logical_window_id().as_str(), "main");Sourcepub const fn presentation_generation(&self) -> PresentationGeneration
pub const fn presentation_generation(&self) -> PresentationGeneration
Returns the native presentation generation that produced the event.
Consumers compare this against a ready crate::app::PresentationLifecycle
to reject stale native events.
§Examples
use std::time::Duration;
use ailloli_ui_runtime::{app::PresentationGeneration, input::{EventId, EventMeta, EventTimestamp}};
let generation = PresentationGeneration::new(4);
let meta = EventMeta::new(EventId::new(1), EventTimestamp::new(Duration::ZERO), "main", generation);
assert_eq!(meta.presentation_generation(), generation);Sourcepub const fn pointer(&self) -> Option<&PointerSample>
pub const fn pointer(&self) -> Option<&PointerSample>
Borrows the optional pointer sample.
None is the default and does not imply mouse, primary, or coordinate
values. A sample can be attached even when the eventual event variant is
not Event::Pointer; consistency is a host responsibility.
§Examples
use std::time::Duration;
use ailloli_ui_runtime::{app::PresentationGeneration, input::{EventId, EventMeta, EventTimestamp}};
let meta = EventMeta::new(EventId::new(1), EventTimestamp::new(Duration::ZERO), "main", PresentationGeneration::INITIAL);
assert!(meta.pointer().is_none());Sourcepub const fn pointer_is_primary(&self) -> Option<bool>
pub const fn pointer_is_primary(&self) -> Option<bool>
Returns the primary classification carried by pointer metadata.
Non-pointer events and legacy direct dispatches have no pointer sample
and therefore return None rather than inventing a classification.
§Examples
use std::time::Duration;
use ailloli_ui_core::{event::{PointerId, PointerSample, PointerSource}, Point};
use ailloli_ui_runtime::{app::PresentationGeneration, input::{EventId, EventMeta, EventTimestamp}};
let sample = PointerSample::new_with_primary(PointerId::new(2), PointerSource::Touch, Point::default(), false)?;
let meta = EventMeta::new(EventId::new(1), EventTimestamp::new(Duration::ZERO), "main", PresentationGeneration::INITIAL).with_pointer(sample);
assert_eq!(meta.pointer_is_primary(), Some(false));Sourcepub const fn with_pointer(self, pointer: PointerSample) -> Self
pub const fn with_pointer(self, pointer: PointerSample) -> Self
Returns this metadata with pointer installed or replaced.
The sample has already validated finite logical position through its own constructor. This builder performs no event-kind consistency check.
§Examples
use std::time::Duration;
use ailloli_ui_core::{event::{PointerId, PointerSample, PointerSource}, Point};
use ailloli_ui_runtime::{app::PresentationGeneration, input::{EventId, EventMeta, EventTimestamp}};
let sample = PointerSample::new(PointerId::MOUSE, PointerSource::Mouse, Point::new(3.0, 4.0))?;
let meta = EventMeta::new(EventId::new(1), EventTimestamp::new(Duration::ZERO), "main", PresentationGeneration::INITIAL).with_pointer(sample);
assert_eq!(meta.pointer().unwrap().position(), Point::new(3.0, 4.0));Trait Implementations§
impl StructuralPartialEq for EventMeta
Auto Trait Implementations§
impl Freeze for EventMeta
impl RefUnwindSafe for EventMeta
impl Send for EventMeta
impl Sync for EventMeta
impl Unpin for EventMeta
impl UnwindSafe for EventMeta
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<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
Source§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.