From 436e12381dd79e419dce755718be17b66d73e17f Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 9 Jun 2026 00:09:08 +0900 Subject: feat(event-dispatcher): unify event dispatch via EventInterface trait Extract a superclass-trait EventInterface from the base Event. pool_builder's PrePoolCreateEvent stays deferred: its constructor needs owned, non-cloneable Request and repository boxes the builder only holds by reference (owned-payload blocker). The event is plugin-only, so its construction is re-tagged TODO(plugin). Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/event_dispatcher/event.rs | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'crates/shirabe/src/event_dispatcher/event.rs') diff --git a/crates/shirabe/src/event_dispatcher/event.rs b/crates/shirabe/src/event_dispatcher/event.rs index 81ab921..f04839f 100644 --- a/crates/shirabe/src/event_dispatcher/event.rs +++ b/crates/shirabe/src/event_dispatcher/event.rs @@ -21,6 +21,10 @@ impl Event { } } + pub fn from_name(name: String) -> Self { + Event::new(name, Vec::new(), IndexMap::new()) + } + pub fn get_name(&self) -> &str { &self.name } @@ -41,3 +45,33 @@ impl Event { self.propagation_stopped = true; } } + +pub trait EventInterface: std::fmt::Debug { + fn get_name(&self) -> &str; + fn get_arguments(&self) -> &Vec; + fn get_flags(&self) -> &IndexMap; + fn is_propagation_stopped(&self) -> bool; + fn stop_propagation(&mut self); +} + +impl EventInterface for Event { + fn get_name(&self) -> &str { + &self.name + } + + fn get_arguments(&self) -> &Vec { + &self.args + } + + fn get_flags(&self) -> &IndexMap { + &self.flags + } + + fn is_propagation_stopped(&self) -> bool { + self.propagation_stopped + } + + fn stop_propagation(&mut self) { + self.propagation_stopped = true; + } +} -- cgit v1.3.1