1use rskit_hook::{Event, EventType};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7#[non_exhaustive]
8pub enum LifecycleEventType {
9 BeforeStart,
11 AfterStart,
13 BeforeStop,
15 AfterStop,
17}
18
19impl LifecycleEventType {
20 #[must_use]
22 pub const fn as_str(self) -> &'static str {
23 match self {
24 Self::BeforeStart => "bootstrap:before_start",
25 Self::AfterStart => "bootstrap:after_start",
26 Self::BeforeStop => "bootstrap:before_stop",
27 Self::AfterStop => "bootstrap:after_stop",
28 }
29 }
30}
31
32#[derive(Debug, Clone, Copy, PartialEq, Eq)]
34pub struct LifecycleEvent {
35 kind: LifecycleEventType,
36}
37
38impl LifecycleEvent {
39 #[must_use]
41 pub const fn new(kind: LifecycleEventType) -> Self {
42 Self { kind }
43 }
44
45 #[must_use]
47 pub const fn kind(&self) -> LifecycleEventType {
48 self.kind
49 }
50}
51
52impl Event for LifecycleEvent {
53 fn event_type(&self) -> EventType {
54 EventType::new(self.kind.as_str())
55 }
56}