use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;
use std::time::Duration;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Language {
Rust,
Python,
JavaScript,
TypeScript,
Wasm,
Command,
}
impl fmt::Display for Language {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Language::Rust => write!(f, "rust"),
Language::Python => write!(f, "python"),
Language::JavaScript => write!(f, "javascript"),
Language::TypeScript => write!(f, "typescript"),
Language::Wasm => write!(f, "wasm"),
Language::Command => write!(f, "command"),
}
}
}
#[derive(Debug, Clone)]
pub struct ExecRequest {
pub language: Language,
pub code: String,
pub stdin: Option<String>,
pub timeout: Duration,
pub memory_limit_mb: Option<u32>,
pub env: HashMap<String, String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExecResult {
pub stdout: String,
pub stderr: String,
pub exit_code: i32,
pub duration: Duration,
}