mina_node/event_source/
event_source_actions.rs

1use serde::{Deserialize, Serialize};
2
3pub type EventSourceActionWithMeta = redux::ActionWithMeta<EventSourceAction>;
4
5#[derive(Serialize, Deserialize, Debug, Clone)]
6#[expect(clippy::large_enum_variant, reason = "This enum wraps super::Event")]
7pub enum EventSourceAction {
8    /// Notify state machine that the new events might be received/available,
9    /// so trigger processing of those events.
10    ///
11    /// This action will be continuously triggered, until there are no more
12    /// events in the queue, in which case `EventSourceWaitForEventsAction`
13    /// will be dispatched.
14    ProcessEvents,
15
16    /// Process newly retrieved event.
17    NewEvent { event: super::Event },
18
19    /// Next action won't be dispatched, until new events are available or
20    /// wait times out.
21    WaitForEvents,
22
23    /// Waiting for events has timed out.
24    WaitTimeout,
25}
26
27impl redux::EnablingCondition<crate::State> for EventSourceAction {
28    fn is_enabled(&self, _: &crate::State, _time: redux::Timestamp) -> bool {
29        match self {
30            EventSourceAction::ProcessEvents => true,
31            EventSourceAction::NewEvent { event: _ } => true,
32            EventSourceAction::WaitForEvents => true,
33            EventSourceAction::WaitTimeout => true,
34        }
35    }
36}