1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
7#[serde(rename_all = "lowercase")]
8pub enum JobStatus {
9 Queued,
10 Running,
11 Proving,
12 Done,
13 Failed,
14 Settled,
15}
16
17impl JobStatus {
18 pub fn is_terminal(&self) -> bool {
20 matches!(self, Self::Failed | Self::Settled)
21 }
22
23 pub fn is_success(&self) -> bool {
25 matches!(self, Self::Settled)
26 }
27}
28
29impl std::fmt::Display for JobStatus {
30 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31 let s = match self {
32 Self::Queued => "queued",
33 Self::Running => "running",
34 Self::Proving => "proving",
35 Self::Done => "done",
36 Self::Failed => "failed",
37 Self::Settled => "settled",
38 };
39 write!(f, "{s}")
40 }
41}
42
43#[derive(Debug, Clone, Serialize)]
47pub(crate) struct SubmitJobRequest {
48 pub input_data: Vec<Vec<f64>>,
49 pub model_id: String,
50}
51
52#[derive(Debug, Clone, Deserialize)]
54pub(crate) struct SubmitJobResponse {
55 pub job_id: String,
56 pub status: String,
57}
58
59#[derive(Debug, Clone, Deserialize)]
65pub struct Job {
66 pub job_id: String,
67 pub status: JobStatus,
68 pub proof_path: Option<String>,
69 pub tx_hash: Option<String>,
70 pub attestation_hash: Option<String>,
72 pub reason: Option<String>,
74}
75
76#[derive(Debug, Clone, Deserialize)]
80pub struct Proof {
81 pub job_id: String,
82 pub proof_hex: String,
83 pub size_bytes: usize,
84}
85
86#[derive(Debug, Clone, Serialize)]
90pub struct RegisterModelRequest {
91 pub name: String,
92 pub version: String,
93 pub artifact_b64: String,
95 pub input_shape: Vec<u64>,
97}
98
99#[derive(Debug, Clone, Deserialize)]
101pub struct RegisterModelResponse {
102 pub model_id: String,
103 pub on_chain_model_id: String,
104 pub ipfs_cid: String,
105 pub gateway_url: String,
106 pub on_chain_hash: String,
107}
108
109#[derive(Debug, Clone, Deserialize)]
113pub struct Health {
114 pub status: String,
115 pub version: String,
116 pub settle_enabled: bool,
117 pub db: String,
118}
119
120impl Health {
121 pub fn is_healthy(&self) -> bool {
123 self.status == "ok" && self.db == "connected"
124 }
125}
126
127#[derive(Debug, Clone)]
131pub struct VerifyResult {
132 pub job_id: String,
134 pub status: JobStatus,
136 pub tx_hash: Option<String>,
138 pub attestation_hash: Option<String>,
141 pub elapsed_ms: u64,
143}