Skip to main content

printobserver_types/
session.rs

1//! The supervision session one print is watched through.
2
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6use crate::ids::PrintId;
7use crate::timestamp::Timestamp;
8
9/// Whether a turn opened a session or continued one.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
11#[serde(rename_all = "snake_case", deny_unknown_fields)]
12pub enum SessionPhase {
13    /// This turn opened the session.
14    Created,
15    /// This turn continued a session already open.
16    Continued,
17}
18
19/// The supervision session keyed to one print.
20#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
21#[serde(deny_unknown_fields)]
22pub struct SupervisionSession {
23    /// The print this session watches.
24    pub print_id: PrintId,
25    /// The session's own name in the harness.
26    pub session_name: String,
27    /// The identity the harness ran the session under.
28    pub harness_identity: String,
29    /// When the session was opened.
30    pub created_at: Timestamp,
31    /// When the last turn ran.
32    pub last_turn_at: Timestamp,
33    /// When the session was closed, if it was.
34    #[serde(default, skip_serializing_if = "Option::is_none")]
35    pub closed_at: Option<Timestamp>,
36    /// Why it was closed, if it was.
37    #[serde(default, skip_serializing_if = "Option::is_none")]
38    pub close_reason: Option<String>,
39}