use std::{fmt::Display, sync::Arc};
use derive_more::Constructor;
use crate::{
actor::{ActorMeta, ActorStatus},
config::AnyConfig,
message,
};
#[message]
#[derive(Eq, PartialEq, Hash, Copy)]
pub enum Impossible {}
#[message(ret = ())]
#[derive(Default)]
#[non_exhaustive]
pub struct Ping;
#[message(ret = Result<(), ConfigRejected>)]
#[derive(Constructor)]
#[non_exhaustive]
pub struct ValidateConfig {
pub config: AnyConfig,
}
#[message(ret = Result<(), ConfigRejected>)]
#[derive(Constructor)]
#[non_exhaustive]
pub struct UpdateConfig {
pub config: AnyConfig,
}
#[message]
#[non_exhaustive]
pub struct ConfigRejected {
pub reason: String,
}
impl<R: Display> From<R> for ConfigRejected {
fn from(reason: R) -> Self {
Self {
reason: reason.to_string(),
}
}
}
#[message(ret = Result<(), StartEntrypointRejected>)]
#[derive(Constructor)]
#[non_exhaustive]
pub struct StartEntrypoint {
pub is_check_only: bool,
}
#[message(part)]
#[derive(Constructor)]
#[non_exhaustive]
pub struct StartEntrypointRejected {
pub errors: Vec<EntrypointError>,
}
#[message(part)]
#[derive(Constructor)]
#[non_exhaustive]
pub struct EntrypointError {
pub group: String,
pub reason: String,
}
#[message]
#[non_exhaustive]
pub struct ConfigUpdated {
}
#[message]
#[derive(Default)]
#[non_exhaustive]
pub struct Terminate {
pub(crate) closing: bool,
}
impl Terminate {
pub fn closing() -> Self {
Self { closing: true }
}
}
#[message]
#[derive(Default)]
#[non_exhaustive]
pub struct SubscribeToActorStatuses {
pub(crate) forcing: bool,
}
impl SubscribeToActorStatuses {
pub fn forcing() -> Self {
Self { forcing: true }
}
}
#[message]
#[non_exhaustive]
pub struct ActorStatusReport {
pub meta: Arc<ActorMeta>,
pub status: ActorStatus,
}