use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TaskOffer {
pub task_id: String,
pub payload_b64: String,
pub max_price_per_hour: f64,
pub estimated_duration_secs: f64,
pub timeout_secs: f64,
#[serde(default = "default_cpus")]
pub cpus: f64,
#[serde(default = "default_memory")]
pub memory_bytes: u64,
#[serde(default)]
pub gpus: u32,
#[serde(default)]
pub worker_type: Option<String>,
#[serde(default)]
pub tags: Vec<String>,
pub requester_user_id: String,
pub source_broker: String,
}
fn default_cpus() -> f64 { 1.0 }
fn default_memory() -> u64 { 1024 * 1024 * 1024 }
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TaskResult {
pub task_id: String,
pub payload_b64: String,
pub duration_ms: f64,
pub actual_cost: f64,
pub worker_name: String,
pub worker_uri: String,
pub price_per_hour: f64,
pub executor_owner: String,
#[serde(default)]
pub worker_pid: Option<String>,
#[serde(default)]
pub worker_ip: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TaskReject {
pub task_id: String,
pub reason: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SubscribeMessage {
pub action: String,
pub peer_url: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PeerIdentity {
pub owner_user_id: String,
pub node_name: String,
pub verified: bool,
pub workers: Vec<WorkerSummary>,
#[serde(default)]
pub quic_port: u16,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkerSummary {
pub name: String,
pub price_per_hour: f64,
pub status: String,
pub cpus: f64,
pub memory_bytes: u64,
pub gpus: u32,
}