use printobserver_types::contract::Sample;
use printobserver_types::schemars::JsonSchema;
use printobserver_types::serde::{Deserialize, Serialize};
use printobserver_types::{PrintId, Timestamp};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(
crate = "printobserver_types::serde",
rename_all = "snake_case",
deny_unknown_fields
)]
#[schemars(crate = "printobserver_types::schemars")]
pub enum SessionPhase {
Created,
Continued,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct SupervisionSession {
pub print_id: PrintId,
pub session_name: String,
pub harness_identity: String,
pub created_at: Timestamp,
pub last_turn_at: Timestamp,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub closed_at: Option<Timestamp>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub close_reason: Option<String>,
}
impl Sample for SessionPhase {
fn sample_full() -> Self {
Self::Created
}
}
impl Sample for SupervisionSession {
fn sample_full() -> Self {
Self {
print_id: PrintId::sample_full(),
session_name: "print-0191f0a0".to_owned(),
harness_identity: "printobserver-supervisor".to_owned(),
created_at: Timestamp::sample_full(),
last_turn_at: later_instant(),
closed_at: Some(later_instant()),
close_reason: Some("the print ended".to_owned()),
}
}
fn sample_minimal() -> Self {
Self {
closed_at: None,
close_reason: None,
..Self::sample_full()
}
}
}
fn later_instant() -> Timestamp {
"2026-03-01T12:30:00Z"
.parse()
.expect("a fixed RFC 3339 instant")
}