use rskit_hook::{Event, EventType};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum LifecycleEventType {
BeforeStart,
AfterStart,
BeforeStop,
AfterStop,
}
impl LifecycleEventType {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::BeforeStart => "bootstrap:before_start",
Self::AfterStart => "bootstrap:after_start",
Self::BeforeStop => "bootstrap:before_stop",
Self::AfterStop => "bootstrap:after_stop",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct LifecycleEvent {
kind: LifecycleEventType,
}
impl LifecycleEvent {
#[must_use]
pub const fn new(kind: LifecycleEventType) -> Self {
Self { kind }
}
#[must_use]
pub const fn kind(&self) -> LifecycleEventType {
self.kind
}
}
impl Event for LifecycleEvent {
fn event_type(&self) -> EventType {
EventType::new(self.kind.as_str())
}
}