use std::time::Instant;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ManualOverride {
ForceEnable,
ForceDisable,
}
#[derive(Debug, Clone, PartialEq)]
pub enum FreeCycleStatus {
Initializing,
Available,
Blocked,
Cooldown {
expires_at: Instant,
},
WakeDelay {
expires_at: Instant,
},
AgentTaskActive,
Downloading,
Error(String),
}
impl FreeCycleStatus {
pub fn label(&self) -> &str {
match self {
Self::Initializing => "Initializing",
Self::Available => "Available",
Self::Blocked => "Blocked (Game Running)",
Self::Cooldown { .. } => "Cooldown",
Self::WakeDelay { .. } => "Wake Delay",
Self::AgentTaskActive => "Agent Task Active",
Self::Downloading => "Downloading Models",
Self::Error(_) => "Error",
}
}
}
impl ManualOverride {
pub fn label(&self) -> &'static str {
match self {
Self::ForceEnable => "Force Enable",
Self::ForceDisable => "Force Disable",
}
}
}
#[derive(Debug, Clone)]
pub struct AgentTask {
pub task_id: String,
pub description: String,
pub started_at: Instant,
pub source_ip: String,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_status_labels() {
assert_eq!(FreeCycleStatus::Initializing.label(), "Initializing");
assert_eq!(FreeCycleStatus::Available.label(), "Available");
assert_eq!(FreeCycleStatus::Blocked.label(), "Blocked (Game Running)");
assert_eq!(
FreeCycleStatus::Cooldown {
expires_at: Instant::now()
}
.label(),
"Cooldown"
);
assert_eq!(
FreeCycleStatus::WakeDelay {
expires_at: Instant::now()
}
.label(),
"Wake Delay"
);
assert_eq!(
FreeCycleStatus::AgentTaskActive.label(),
"Agent Task Active"
);
assert_eq!(FreeCycleStatus::Downloading.label(), "Downloading Models");
assert_eq!(FreeCycleStatus::Error("test".into()).label(), "Error");
}
#[test]
fn test_agent_task_creation() {
let task = AgentTask {
task_id: "task-001".to_string(),
description: "Running inference batch".to_string(),
started_at: Instant::now(),
source_ip: "192.168.1.50".to_string(),
};
assert_eq!(task.task_id, "task-001");
assert_eq!(task.description, "Running inference batch");
}
#[test]
fn test_manual_override_labels() {
assert_eq!(ManualOverride::ForceEnable.label(), "Force Enable");
assert_eq!(ManualOverride::ForceDisable.label(), "Force Disable");
}
}