Skip to main content

dvm_api/
execution.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{Run, Sandbox, SandboxId, SandboxSpec};
4
5/// A sandbox's execution, `GET /api/executions/{id}`: what it ran, one log
6/// from its start to its end, under its sandbox's id. Its spec, its seed
7/// among it; its run, how and when it ended, and its log's size; and its
8/// replays.
9#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
10#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
11#[cfg_attr(feature = "typescript", ts(export_to = "controller-api.ts"))]
12pub struct Execution {
13    pub id: SandboxId,
14    /// Its owner's GitHub login; none for one made before users signed in,
15    /// which only admins see.
16    pub owner: Option<String>,
17    pub spec: SandboxSpec,
18    pub run: Run,
19    /// Oldest first.
20    pub replays: Vec<Run>,
21}
22
23impl From<Sandbox> for Execution {
24    fn from(sandbox: Sandbox) -> Self {
25        Self {
26            id: sandbox.id,
27            owner: sandbox.owner,
28            spec: sandbox.spec,
29            run: sandbox.run,
30            replays: sandbox.replays,
31        }
32    }
33}