Skip to main content

euv_core/event/handler/
struct.rs

1use crate::*;
2
3/// Inner storage for a native event callback closure.
4///
5/// Boxes a `dyn FnMut(Event)` so it can be stored behind `Rc<RefCell<>>`.
6#[derive(CustomDebug, Data, New)]
7pub(crate) struct NativeEventCallbackInner {
8    /// The boxed callback closure.
9    #[debug(skip)]
10    #[get(pub(crate))]
11    #[set(pub(crate))]
12    pub(crate) callback: Box<dyn FnMut(Event)>,
13}
14
15/// A wrapper around an event callback.
16///
17/// Stores the event name and a shared reference to the heap-allocated callback closure.
18#[derive(Clone, CustomDebug, Data, New)]
19pub struct NativeEventHandler {
20    /// The name of the event (e.g., "click", "input").
21    #[get(pub(crate))]
22    #[set(pub(crate))]
23    pub(crate) event_name: Cow<'static, str>,
24    /// Shared reference to the heap-allocated callback closure inner state.
25    #[debug(skip)]
26    #[get(pub(crate))]
27    #[set(pub(crate))]
28    pub(crate) callback: Rc<RefCell<NativeEventCallbackInner>>,
29}