use std::fmt::{Debug, Display};
#[cfg(doc)]
use super::{Worker, WorkerBuilder};
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum StopReason {
#[default]
GracefulShutdown,
ServerInstruction,
}
impl Display for StopReason {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Debug::fmt(&self, f)
}
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct StopDetails {
pub reason: StopReason,
pub workers_still_running: usize,
}
impl StopDetails {
pub(crate) fn new(reason: StopReason, nrunning: usize) -> Self {
StopDetails {
reason,
workers_still_running: nrunning,
}
}
}