Skip to main content

aj_models/
verdicts.rs

1use std::fmt;
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
6#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
7#[cfg_attr(
8    feature = "sqlx",
9    sqlx(type_name = "verdict", rename_all = "snake_case")
10)]
11#[serde(rename_all = "snake_case")]
12pub enum Verdict {
13    Ok,
14    RuntimeError,
15    TimeLimitExceeded,
16    MemoryLimitExceeded,
17    SecurityError,
18    WrongAnswer,
19    PresentationError,
20    Skipped,
21    Testing,
22    Fail,
23}
24
25#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
26#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
27#[cfg_attr(
28    feature = "sqlx",
29    sqlx(type_name = "testing_verdict", rename_all = "snake_case")
30)]
31#[serde(rename_all = "snake_case")]
32pub enum TestingVerdict {
33    Ok,
34    PartialSolution,
35    Pending,
36    Compiling,
37    CompilationError,
38    Testing,
39    Fail,
40}
41
42impl fmt::Display for TestingVerdict {
43    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
44        let converted = match self {
45            Self::Ok => "Ok",
46            Self::PartialSolution => "PartialSolution",
47            Self::Pending => "Pending",
48            Self::Compiling => "Compiling",
49            Self::CompilationError => "CompilationError",
50            Self::Testing => "Testing",
51            Self::Fail => "Fail",
52        };
53        write!(f, "{converted}")
54    }
55}
56
57impl std::error::Error for TestingVerdict {}