//! Daemon state machine module.

mod machine;

pub use machine::{DaemonState, DaemonStateMachine, StateTransition};

use serde::{Deserialize, Serialize};

/// Daemon status for external reporting.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum DaemonStatus {
    /// Daemon is idle, waiting for League Client.
    Idle,
    /// Daemon is monitoring for game start.
    Monitoring,
    /// Daemon is actively recording.
    Recording,
    /// Daemon encountered an error.
    Error,
    /// Daemon is shutting down.
    ShuttingDown,
}

impl std::fmt::Display for DaemonStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            DaemonStatus::Idle => write!(f, "Idle"),
            DaemonStatus::Monitoring => write!(f, "Monitoring"),
            DaemonStatus::Recording => write!(f, "Recording"),
            DaemonStatus::Error => write!(f, "Error"),
            DaemonStatus::ShuttingDown => write!(f, "Shutting Down"),
        }
    }
}
