Skip to main content

ai_agent/interact/events/
event.rs

1// Source: ~/claudecode/openclaudecode/src/ink/events/event.ts
2
3use std::sync::atomic::{AtomicBool, Ordering};
4
5/// Base event class for all ink events.
6/// Supports stop_immediate_propagation() to prevent downstream listeners from firing.
7#[derive(Debug)]
8pub struct Event {
9    did_stop_immediate_propagation: AtomicBool,
10}
11
12impl Event {
13    pub fn new() -> Self {
14        Self {
15            did_stop_immediate_propagation: AtomicBool::new(false),
16        }
17    }
18
19    pub fn did_stop_immediate_propagation(&self) -> bool {
20        self.did_stop_immediate_propagation.load(Ordering::SeqCst)
21    }
22
23    pub fn stop_immediate_propagation(&self) {
24        self.did_stop_immediate_propagation
25            .store(true, Ordering::SeqCst);
26    }
27}
28
29impl Default for Event {
30    fn default() -> Self {
31        Self::new()
32    }
33}
34
35impl Clone for Event {
36    fn clone(&self) -> Self {
37        Self {
38            did_stop_immediate_propagation: AtomicBool::new(
39                self.did_stop_immediate_propagation.load(Ordering::SeqCst),
40            ),
41        }
42    }
43}