1use std::{fmt::Display, sync::Arc};
2
3use derive_more::Constructor;
4
5use elfo_macros::message;
6
7use crate::{
8    actor::{ActorMeta, ActorStatus},
9    config::AnyConfig,
10};
11
12#[message(ret = (), elfo = crate)]
15pub struct Ping;
16
17#[message(ret = Result<(), ConfigRejected>, elfo = crate)]
18#[derive(Constructor)]
19pub struct ValidateConfig {
20    pub config: AnyConfig,
21}
22
23#[message(ret = Result<(), ConfigRejected>, elfo = crate)]
24#[derive(Constructor)]
25pub struct UpdateConfig {
26    pub config: AnyConfig,
27}
28
29#[message(elfo = crate)]
30pub struct ConfigRejected {
31    pub reason: String,
32}
33
34impl<R: Display> From<R> for ConfigRejected {
35    fn from(reason: R) -> Self {
36        Self {
37            reason: reason.to_string(),
38        }
39    }
40}
41
42#[message(elfo = crate)]
43pub struct ConfigUpdated {
44    }
46
47#[message(elfo = crate)]
48#[derive(Default)]
49pub struct Terminate {
50    pub(crate) closing: bool,
51}
52
53impl Terminate {
54    pub fn closing() -> Self {
56        Self { closing: true }
57    }
58}
59
60#[message(elfo = crate)]
64#[derive(Default)]
65#[non_exhaustive]
66pub struct SubscribeToActorStatuses {}
67
68#[message(elfo = crate)]
69#[non_exhaustive]
70pub struct ActorStatusReport {
71    pub meta: Arc<ActorMeta>,
72    pub status: ActorStatus,
73}