use crate::error::ExecutorError;
use crate::task_id::TaskId;
#[derive(Clone, Debug, Default)]
#[non_exhaustive]
pub struct UserEvent {
pub kind: u32,
pub int_data: i64,
pub string_data: Option<String>,
}
impl UserEvent {
#[must_use]
pub const fn new(kind: u32, int_data: i64) -> Self {
Self {
kind,
int_data,
string_data: None,
}
}
#[must_use]
pub fn with_string(mut self, s: impl Into<String>) -> Self {
self.string_data = Some(s.into());
self
}
}
pub trait Observer: Send + Sync {
fn on_executor_up(&self) {}
fn on_executor_down(&self) {}
fn on_executor_error(&self, _e: &ExecutorError) {}
fn on_app_start(&self, _task: TaskId, _app: u32, _instance: Option<u32>) {}
fn on_app_stop(&self, _task: TaskId) {}
fn on_app_error(&self, _task: TaskId, _e: &(dyn std::error::Error + 'static)) {}
fn on_send_event(&self, _task: TaskId, _ev: UserEvent) {}
}
pub struct NoopObserver;
impl Observer for NoopObserver {}