Struct EventMeta

Source
#[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.

Source

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());
Source

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);
Source

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);
Source

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");
Source

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);
Source

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());
Source

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));
Source

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§

Source§

impl Clone for EventMeta

Source§

fn clone(&self) -> EventMeta

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EventMeta

Source§

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

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

impl PartialEq for EventMeta

Source§

fn eq(&self, other: &EventMeta) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for EventMeta

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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<A> IntoClickAction<A> for A
where A: Clone + 'static,

Source§

fn into_click_action(self) -> ClickAction<A>

Implements the into_click_action helper used by this module.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Props for T
where T: Clone + 'static,