use crate::records::{
AcknowledgementDisposition, ActionId, Actor, ChargeKey, ChargeMethod, ChargedFilament,
ClearedMark, FilePosition, InterventionId, InterventionOutcome, LoadedSpool, PendingCharge,
PendingTaken, PolicyDecision, Preflight, PrintAction, PrintOutcome, SpoolCommand, SpoolId,
SpoolRecord, UnverifiedReason,
};
use printobserver_printer_api::{Adjustable, JobSnapshot, PrinterSnapshot, PrinterState};
use printobserver_supervisor_api::AgentAssessment;
use printobserver_types::contract::Sample;
use printobserver_types::schemars::JsonSchema;
use printobserver_types::serde::{Deserialize, Serialize};
use printobserver_types::{EventId, EventKind, EventPayload, EventSource, Timestamp};
pub const SYSTEM_SOURCE: &str = "system";
pub const OPERATOR_SOURCE: &str = "operator";
pub const AGENT_SOURCE: &str = "agent";
#[must_use]
pub fn system_source() -> EventSource {
EventSource::new(SYSTEM_SOURCE)
}
#[must_use]
pub fn operator_source() -> EventSource {
EventSource::new(OPERATOR_SOURCE)
}
#[must_use]
pub fn agent_source() -> EventSource {
EventSource::new(AGENT_SOURCE)
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct ActionRequestedPayload {
pub action_id: ActionId,
pub action: PrintAction,
pub actor: Actor,
}
impl EventPayload for ActionRequestedPayload {
const KIND: &'static str = "action_requested";
}
impl Sample for ActionRequestedPayload {
fn sample_full() -> Self {
Self {
action_id: ActionId::sample_full(),
action: PrintAction::sample_full(),
actor: Actor::sample_full(),
}
}
fn sample_minimal() -> Self {
Self {
action: PrintAction::sample_minimal(),
..Self::sample_full()
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct ActionExecutedPayload {
pub action_id: ActionId,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub intervention_id: Option<InterventionId>,
}
impl EventPayload for ActionExecutedPayload {
const KIND: &'static str = "action_executed";
}
impl Sample for ActionExecutedPayload {
fn sample_full() -> Self {
Self {
action_id: ActionId::sample_full(),
intervention_id: Some(InterventionId::sample_full()),
}
}
fn sample_minimal() -> Self {
Self {
action_id: ActionId::sample_full(),
intervention_id: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct ActionRejectedPayload {
pub action_id: ActionId,
pub decision: PolicyDecision,
}
impl EventPayload for ActionRejectedPayload {
const KIND: &'static str = "action_rejected";
}
impl Sample for ActionRejectedPayload {
fn sample_full() -> Self {
Self {
action_id: ActionId::sample_full(),
decision: PolicyDecision::sample_full(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct InterventionExpiredPayload {
pub intervention_id: InterventionId,
pub adjustable: Adjustable,
pub outcome: InterventionOutcome,
}
impl EventPayload for InterventionExpiredPayload {
const KIND: &'static str = "intervention_expired";
}
impl Sample for InterventionExpiredPayload {
fn sample_full() -> Self {
Self {
intervention_id: InterventionId::sample_full(),
adjustable: Adjustable::Feedrate,
outcome: InterventionOutcome::Restored,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct AgentAssessmentPayload {
pub session_name: String,
pub assessment: AgentAssessment,
}
impl EventPayload for AgentAssessmentPayload {
const KIND: &'static str = "agent_assessment";
}
impl Sample for AgentAssessmentPayload {
fn sample_full() -> Self {
Self {
session_name: "print-0191f0a0".to_owned(),
assessment: AgentAssessment::sample_full(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct OperatorAcknowledgementPayload {
pub acknowledged_event_id: EventId,
pub disposition: AcknowledgementDisposition,
}
impl EventPayload for OperatorAcknowledgementPayload {
const KIND: &'static str = "operator_acknowledgement";
}
impl Sample for OperatorAcknowledgementPayload {
fn sample_full() -> Self {
Self {
acknowledged_event_id: EventId::sample_full(),
disposition: AcknowledgementDisposition::Watch,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct CameraLookPayload {
pub waited_s: u32,
#[serde(default)]
pub delivered: Vec<EventId>,
}
impl EventPayload for CameraLookPayload {
const KIND: &'static str = "camera_look";
}
impl Sample for CameraLookPayload {
fn sample_full() -> Self {
Self {
waited_s: 60,
delivered: vec![EventId::sample_full()],
}
}
fn sample_minimal() -> Self {
Self {
waited_s: 0,
delivered: Vec::new(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct PeriodicObservationPayload {
pub interval_s: u64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub printer: Option<PrinterSnapshot>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub job: Option<JobSnapshot>,
}
impl EventPayload for PeriodicObservationPayload {
const KIND: &'static str = "periodic_observation";
}
impl Sample for PeriodicObservationPayload {
fn sample_full() -> Self {
Self {
interval_s: 120,
printer: Some(PrinterSnapshot::sample_full()),
job: Some(JobSnapshot::sample_full()),
}
}
fn sample_minimal() -> Self {
Self {
interval_s: 120,
printer: None,
job: None,
}
}
}
#[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 PortFailureSite {
PrinterSnapshot,
PrinterJob,
ImageWrite,
SupervisionTurn,
CameraLook,
DetectorAcknowledgement,
}
impl Sample for PortFailureSite {
fn sample_full() -> Self {
Self::PrinterSnapshot
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct PortFailurePayload {
pub event_id: EventId,
pub site: PortFailureSite,
pub detail: String,
}
impl EventPayload for PortFailurePayload {
const KIND: &'static str = "port_failure";
}
impl Sample for PortFailurePayload {
fn sample_full() -> Self {
Self {
event_id: EventId::sample_full(),
site: PortFailureSite::sample_full(),
detail: "the printer is unreachable: connection refused".to_owned(),
}
}
}
pub const TIMELINE_KINDS: [&str; 16] = [
PrintStartedPayload::KIND,
PrintEndedPayload::KIND,
FilamentConsumedPayload::KIND,
SpoolRegisteredPayload::KIND,
SpoolLoadedPayload::KIND,
SpoolUnloadedPayload::KIND,
SpoolAdjustedPayload::KIND,
SpoolRetiredPayload::KIND,
SpoolCommandRejectedPayload::KIND,
SpoolUnverifiedPayload::KIND,
FilamentChangeSignalledPayload::KIND,
UnaccountedPrintPayload::KIND,
PreflightCheckedPayload::KIND,
ChargePendedPayload::KIND,
PrintUntrackedPayload::KIND,
FileTallyRebaselinedPayload::KIND,
];
fn sample_spool_id() -> SpoolId {
SpoolId::sample_full()
}
fn sample_reason() -> String {
"the spool on the shelf changed".to_owned()
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct PrintStartedPayload {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub file_name: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub started_by: Option<ActionId>,
pub loaded: Vec<LoadedSpool>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub preflight: Option<Preflight>,
}
impl EventPayload for PrintStartedPayload {
const KIND: &'static str = "print_started";
}
impl Sample for PrintStartedPayload {
fn sample_full() -> Self {
Self {
file_name: Some("benchy.gcode".to_owned()),
started_by: Some(ActionId::sample_full()),
loaded: vec![LoadedSpool::sample_full()],
preflight: Some(Preflight::sample_full()),
}
}
fn sample_minimal() -> Self {
Self {
file_name: None,
started_by: None,
loaded: Vec::new(),
preflight: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct PrintEndedPayload {
pub outcome: PrintOutcome,
pub state: PrinterState,
pub reason: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub last_position: Option<FilePosition>,
}
impl EventPayload for PrintEndedPayload {
const KIND: &'static str = "print_ended";
}
impl Sample for PrintEndedPayload {
fn sample_full() -> Self {
Self {
outcome: PrintOutcome::Cancelled,
state: PrinterState::Cancelling,
reason: "the operator cancelled it".to_owned(),
last_position: Some(FilePosition::sample_full()),
}
}
fn sample_minimal() -> Self {
Self {
outcome: PrintOutcome::Completed,
state: PrinterState::Operational,
reason: "finished".to_owned(),
last_position: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct FilamentConsumedPayload {
pub charge_key: ChargeKey,
pub tool: i64,
pub method: ChargeMethod,
pub length_mm: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub charged: Option<ChargedFilament>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub analysed_length_mm: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub position: Option<FilePosition>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub note: Option<String>,
}
impl EventPayload for FilamentConsumedPayload {
const KIND: &'static str = "filament_consumed";
}
impl Sample for FilamentConsumedPayload {
fn sample_full() -> Self {
Self {
charge_key: ChargeKey::sample_full(),
tool: 0,
method: ChargeMethod::GcodeExtrusion,
length_mm: 1_000.0,
charged: Some(ChargedFilament::sample_full()),
analysed_length_mm: Some(5_120.0),
position: Some(FilePosition::sample_full()),
note: Some("charged up to the filament change".to_owned()),
}
}
fn sample_minimal() -> Self {
Self {
charge_key: ChargeKey::sample_full(),
tool: 0,
method: ChargeMethod::SlicerEstimate,
length_mm: 5_120.0,
charged: None,
analysed_length_mm: None,
position: None,
note: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct SpoolRegisteredPayload {
pub spool: SpoolRecord,
pub actor: Actor,
pub reason: String,
}
impl EventPayload for SpoolRegisteredPayload {
const KIND: &'static str = "spool_registered";
}
impl Sample for SpoolRegisteredPayload {
fn sample_full() -> Self {
Self {
spool: SpoolRecord::sample_full(),
actor: Actor::Operator,
reason: sample_reason(),
}
}
fn sample_minimal() -> Self {
Self {
spool: SpoolRecord::sample_minimal(),
..Self::sample_full()
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct SpoolLoadedPayload {
pub spool_id: SpoolId,
pub tool: i64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub replaced: Option<SpoolId>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub took_pending: Vec<PendingTaken>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub cleared_marks: Vec<ClearedMark>,
pub actor: Actor,
pub reason: String,
}
impl EventPayload for SpoolLoadedPayload {
const KIND: &'static str = "spool_loaded";
}
impl Sample for SpoolLoadedPayload {
fn sample_full() -> Self {
Self {
spool_id: sample_spool_id(),
tool: 0,
replaced: Some(ClearedMark::sample_full().spool_id),
took_pending: vec![PendingTaken::sample_full()],
cleared_marks: vec![ClearedMark::sample_full()],
actor: Actor::Operator,
reason: sample_reason(),
}
}
fn sample_minimal() -> Self {
Self {
replaced: None,
took_pending: Vec::new(),
cleared_marks: Vec::new(),
..Self::sample_full()
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct SpoolUnloadedPayload {
pub spool_id: SpoolId,
pub tool: i64,
pub actor: Actor,
pub reason: String,
}
impl EventPayload for SpoolUnloadedPayload {
const KIND: &'static str = "spool_unloaded";
}
impl Sample for SpoolUnloadedPayload {
fn sample_full() -> Self {
Self {
spool_id: sample_spool_id(),
tool: 0,
actor: Actor::Operator,
reason: sample_reason(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct SpoolAdjustedPayload {
pub spool_id: SpoolId,
pub remaining_before_g: f64,
pub remaining_after_g: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub gross_g: Option<f64>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub took_pending: Vec<PendingTaken>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub cleared_marks: Vec<ClearedMark>,
pub actor: Actor,
pub reason: String,
}
impl EventPayload for SpoolAdjustedPayload {
const KIND: &'static str = "spool_adjusted";
}
impl Sample for SpoolAdjustedPayload {
fn sample_full() -> Self {
Self {
spool_id: sample_spool_id(),
remaining_before_g: 742.5,
remaining_after_g: 700.0,
gross_g: Some(950.0),
took_pending: vec![PendingTaken::sample_full()],
cleared_marks: vec![ClearedMark {
spool_id: sample_spool_id(),
reason: UnverifiedReason::sample_full(),
}],
actor: Actor::Operator,
reason: sample_reason(),
}
}
fn sample_minimal() -> Self {
Self {
gross_g: None,
took_pending: Vec::new(),
cleared_marks: Vec::new(),
..Self::sample_full()
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct SpoolRetiredPayload {
pub spool_id: SpoolId,
pub remaining_g: f64,
pub actor: Actor,
pub reason: String,
}
impl EventPayload for SpoolRetiredPayload {
const KIND: &'static str = "spool_retired";
}
impl Sample for SpoolRetiredPayload {
fn sample_full() -> Self {
Self {
spool_id: sample_spool_id(),
remaining_g: 12.5,
actor: Actor::Operator,
reason: "the spool is empty".to_owned(),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct SpoolCommandRejectedPayload {
pub command: SpoolCommand,
pub decision: PolicyDecision,
}
impl EventPayload for SpoolCommandRejectedPayload {
const KIND: &'static str = "spool_command_rejected";
}
impl Sample for SpoolCommandRejectedPayload {
fn sample_full() -> Self {
Self {
command: SpoolCommand::sample_full(),
decision: PolicyDecision::Rejected(crate::records::RejectionReason::SpoolRefused {
cause: crate::records::SpoolRefusalCause::DensityRequired {
spool_id: None,
material: "PEEK".to_owned(),
},
message: "PEEK has no known density, so the spool needs one".to_owned(),
}),
}
}
fn sample_minimal() -> Self {
Self {
command: SpoolCommand::sample_minimal(),
..Self::sample_full()
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct SpoolUnverifiedPayload {
pub spool_id: SpoolId,
pub reason: UnverifiedReason,
}
impl EventPayload for SpoolUnverifiedPayload {
const KIND: &'static str = "spool_unverified";
}
impl Sample for SpoolUnverifiedPayload {
fn sample_full() -> Self {
Self {
spool_id: sample_spool_id(),
reason: UnverifiedReason::sample_full(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct FilamentChangeSignalledPayload {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tool: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub spool_id: Option<SpoolId>,
pub source_kind: EventKind,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub position: Option<SignalPosition>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct SignalPosition {
pub position: FilePosition,
pub freshness: PositionFreshness,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", rename_all = "snake_case")]
#[schemars(crate = "printobserver_types::schemars")]
pub enum PositionFreshness {
ReadAtSignal,
LastRecorded,
}
impl EventPayload for FilamentChangeSignalledPayload {
const KIND: &'static str = "filament_change_signalled";
}
impl Sample for FilamentChangeSignalledPayload {
fn sample_full() -> Self {
Self {
tool: Some(0),
spool_id: Some(sample_spool_id()),
source_kind: EventKind::new("obico_printer_notification").expect("a kind name"),
position: Some(SignalPosition {
position: FilePosition::sample_full(),
freshness: PositionFreshness::ReadAtSignal,
}),
}
}
fn sample_minimal() -> Self {
Self {
tool: None,
spool_id: None,
position: None,
..Self::sample_full()
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct UnaccountedPrintPayload {
pub file_name: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub printed_at: Option<Timestamp>,
pub success: bool,
pub charged: bool,
}
impl EventPayload for UnaccountedPrintPayload {
const KIND: &'static str = "unaccounted_print";
}
impl Sample for UnaccountedPrintPayload {
fn sample_full() -> Self {
Self {
file_name: "benchy.gcode".to_owned(),
printed_at: Some(Timestamp::sample_full()),
success: true,
charged: true,
}
}
fn sample_minimal() -> Self {
Self {
printed_at: None,
success: false,
charged: false,
..Self::sample_full()
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct PreflightCheckedPayload {
pub preflight: Preflight,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub action_id: Option<ActionId>,
}
impl EventPayload for PreflightCheckedPayload {
const KIND: &'static str = "preflight_checked";
}
impl Sample for PreflightCheckedPayload {
fn sample_full() -> Self {
Self {
preflight: Preflight::sample_full(),
action_id: Some(ActionId::sample_full()),
}
}
fn sample_minimal() -> Self {
Self {
action_id: None,
..Self::sample_full()
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct ChargePendedPayload {
pub pending: PendingCharge,
}
impl EventPayload for ChargePendedPayload {
const KIND: &'static str = "charge_pended";
}
impl Sample for ChargePendedPayload {
fn sample_full() -> Self {
Self {
pending: PendingCharge::sample_full(),
}
}
fn sample_minimal() -> Self {
Self {
pending: PendingCharge::sample_minimal(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct PrintUntrackedPayload {
pub reason: String,
}
impl EventPayload for PrintUntrackedPayload {
const KIND: &'static str = "print_untracked";
}
impl Sample for PrintUntrackedPayload {
fn sample_full() -> Self {
Self {
reason: "the print was already running when spool tracking was installed".to_owned(),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", rename_all = "snake_case")]
#[schemars(crate = "printobserver_types::schemars")]
pub enum RebaselineDisposition {
Accounted,
Unverified,
}
impl Sample for RebaselineDisposition {
fn sample_full() -> Self {
Self::Unverified
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
#[schemars(crate = "printobserver_types::schemars")]
pub struct FileTallyRebaselinedPayload {
pub file_name: String,
pub origin: String,
pub old_generation: u32,
pub new_generation: u32,
pub old_successes: i64,
pub old_failures: i64,
pub new_successes: i64,
pub new_failures: i64,
pub disposition: RebaselineDisposition,
}
impl EventPayload for FileTallyRebaselinedPayload {
const KIND: &'static str = "file_tally_rebaselined";
}
impl Sample for FileTallyRebaselinedPayload {
fn sample_full() -> Self {
Self {
file_name: "benchy.gcode".to_owned(),
origin: "local".to_owned(),
old_generation: 0,
new_generation: 1,
old_successes: 5,
old_failures: 1,
new_successes: 1,
new_failures: 0,
disposition: RebaselineDisposition::Unverified,
}
}
fn sample_alternates() -> Vec<Self> {
vec![Self {
disposition: RebaselineDisposition::Accounted,
..Self::sample_full()
}]
}
}