Skip to main content

printobserver_core/records/
samples.rs

1//! The canonical values of every record this domain declares.
2//!
3//! One value carrying every field, one carrying every optional field absent,
4//! and one per further arm of a union: what the schema set and the round-trip
5//! corpus are walked over. They are here rather than beside each record so
6//! that the records read as the data they are, and so that the fixed
7//! identifiers and instants the samples share are written once.
8
9use std::collections::BTreeMap;
10
11use printobserver_printer_api::{Adjustable, PrinterState};
12use printobserver_types::contract::Sample;
13use printobserver_types::{EventId, FileName, ImageId, PrintId, Range, Timestamp};
14
15use super::action::{
16    AcknowledgementDisposition, ActionKind, ActionRecord, ActionRequest, Actor, ActorClass,
17    ExecutionOutcome, PrintAction,
18};
19use super::charge::{
20    ChargeKey, ChargeMethod, ChargedFilament, FilePosition, PendingCharge, PendingTaken,
21    PrintOutcome, PrintSegmentKey,
22};
23use super::ids::{ActionId, InterventionId, SpoolId};
24use super::image::ImageRecord;
25use super::intervention::{Intervention, InterventionOutcome};
26use super::manifest::JobManifest;
27use super::policy::{
28    EffectiveBounds, PolicyDecision, RejectionReason, SafetyEnvelope, SpoolField, SpoolRefusalCause,
29};
30use super::preflight::{
31    DoubtedSpool, Preflight, PreflightNeed, PreflightObjection, PreflightSpool, PreflightTool,
32    PreflightToolResult, PreflightVerdict, ShortSpool, UnanalysedSpool,
33};
34use super::print::{ManifestNarrowing, PrintRecord};
35use super::spool::{
36    ClearedMark, LoadedSpool, SpoolLifecycle, SpoolRecord, SpoolTrust, UnverifiedMark,
37    UnverifiedMarks, UnverifiedReason,
38};
39use super::spool_command::SpoolCommand;
40
41/// A later fixed instant than the one the type crate's sample carries.
42fn later_instant() -> Timestamp {
43    "2026-03-01T12:30:00Z"
44        .parse()
45        .expect("a fixed RFC 3339 instant")
46}
47
48/// A fixed action identifier.
49fn action_id() -> ActionId {
50    "0191f0a0-0000-7000-8000-000000000004"
51        .parse()
52        .expect("a fixed version 7 identifier")
53}
54
55/// A fixed intervention identifier.
56fn intervention_id() -> InterventionId {
57    "0191f0a0-0000-7000-8000-000000000005"
58        .parse()
59        .expect("a fixed version 7 identifier")
60}
61
62/// A fixed spool identifier.
63fn spool_id() -> SpoolId {
64    "0191f0a0-0000-7000-8000-000000000006"
65        .parse()
66        .expect("a fixed version 7 identifier")
67}
68
69/// A second fixed spool identifier, for the spool a swap replaced.
70fn replaced_spool_id() -> SpoolId {
71    "0191f0a0-0000-7000-8000-000000000007"
72        .parse()
73        .expect("a fixed version 7 identifier")
74}
75
76impl Sample for SpoolId {
77    fn sample_full() -> Self {
78        spool_id()
79    }
80}
81
82impl Sample for ActionId {
83    fn sample_full() -> Self {
84        action_id()
85    }
86}
87
88impl Sample for InterventionId {
89    fn sample_full() -> Self {
90        intervention_id()
91    }
92}
93
94impl Sample for ManifestNarrowing {
95    fn sample_full() -> Self {
96        Self {
97            adjustable: Adjustable::Feedrate,
98            requested: Range::new(0.2, 4.0),
99            applied: Range::new(0.5, 1.5),
100        }
101    }
102}
103
104impl Sample for PrintRecord {
105    fn sample_full() -> Self {
106        Self {
107            id: PrintId::sample_full(),
108            provider_print_id: Some(4211),
109            file_name: Some("benchy.gcode".to_owned()),
110            state: PrinterState::Printing,
111            opened_at: Timestamp::sample_full(),
112            job_started_at: Some(Timestamp::sample_full()),
113            job_print_time_s: Some(3024),
114            ended_at: Some(later_instant()),
115            end_reason: Some("finished".to_owned()),
116            narrowings: vec![ManifestNarrowing::sample_full()],
117        }
118    }
119
120    fn sample_minimal() -> Self {
121        Self {
122            id: PrintId::sample_full(),
123            provider_print_id: None,
124            file_name: None,
125            state: PrinterState::Printing,
126            opened_at: Timestamp::sample_full(),
127            job_started_at: None,
128            job_print_time_s: None,
129            ended_at: None,
130            end_reason: None,
131            narrowings: vec![],
132        }
133    }
134}
135
136impl Sample for ImageRecord {
137    fn sample_full() -> Self {
138        Self {
139            id: ImageId::sample_full(),
140            print_id: PrintId::sample_full(),
141            event_id: EventId::sample_full(),
142            source_url: Some("https://detector.example/snapshots/1.jpg".to_owned()),
143            fetched_at: Timestamp::sample_full(),
144            content_type: "image/jpeg".to_owned(),
145            byte_len: 51_200,
146            sha256: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855".to_owned(),
147            relative_path: "images/0191f0a0/1.jpg".to_owned(),
148        }
149    }
150
151    fn sample_minimal() -> Self {
152        Self {
153            source_url: None,
154            ..Self::sample_full()
155        }
156    }
157}
158
159impl Sample for Actor {
160    fn sample_full() -> Self {
161        Self::Agent {
162            session_name: "print-0191f0a0".to_owned(),
163        }
164    }
165}
166
167impl Sample for ActorClass {
168    fn sample_full() -> Self {
169        Self::Agent
170    }
171}
172
173impl Sample for ActionKind {
174    fn sample_full() -> Self {
175        Self::SetFeedrateFactor
176    }
177}
178
179impl Sample for AcknowledgementDisposition {
180    fn sample_full() -> Self {
181        Self::Watch
182    }
183}
184
185impl Sample for ExecutionOutcome {
186    fn sample_full() -> Self {
187        Self::Failed {
188            reason: "the printer refused the command".to_owned(),
189        }
190    }
191}
192
193impl Sample for PrintAction {
194    fn sample_full() -> Self {
195        Self::SetFeedrateFactor {
196            factor: 0.8,
197            duration_s: Some(600),
198            reason: "the first layer is going down fast".to_owned(),
199            actor: Actor::sample_full(),
200        }
201    }
202
203    fn sample_minimal() -> Self {
204        Self::SetFeedrateFactor {
205            factor: 0.8,
206            duration_s: None,
207            reason: "the first layer is going down fast".to_owned(),
208            actor: Actor::sample_full(),
209        }
210    }
211
212    fn sample_alternates() -> Vec<Self> {
213        let reason = || "the print needs it".to_owned();
214        vec![
215            Self::Pause {
216                reason: reason(),
217                actor: Actor::sample_full(),
218            },
219            Self::Resume {
220                reason: reason(),
221                actor: Actor::sample_full(),
222            },
223            Self::Cancel {
224                reason: reason(),
225                actor: Actor::sample_full(),
226            },
227            Self::StartPrint {
228                file_name: FileName::sample_full(),
229                manifest: JobManifest::sample_full(),
230                override_filament_check: true,
231                reason: reason(),
232                actor: Actor::sample_full(),
233            },
234            Self::SetFlowrateFactor {
235                factor: 1.05,
236                duration_s: Some(300),
237                reason: reason(),
238                actor: Actor::sample_full(),
239            },
240            Self::SetToolTargetC {
241                tool: 0,
242                target_c: 215.0,
243                duration_s: Some(300),
244                reason: reason(),
245                actor: Actor::sample_full(),
246            },
247            Self::SetBedTargetC {
248                target_c: 60.0,
249                duration_s: Some(300),
250                reason: reason(),
251                actor: Actor::sample_full(),
252            },
253            Self::SetFanPercent {
254                percent: 80.0,
255                duration_s: Some(300),
256                reason: reason(),
257                actor: Actor::sample_full(),
258            },
259            Self::AcknowledgeFailure {
260                event_id: EventId::sample_full(),
261                disposition: AcknowledgementDisposition::Watch,
262                reason: reason(),
263                actor: Actor::Operator,
264            },
265        ]
266    }
267}
268
269impl Sample for ActionRequest {
270    fn sample_full() -> Self {
271        Self {
272            action: PrintAction::sample_full(),
273            actor: Actor::sample_full(),
274            requested_at: Timestamp::sample_full(),
275        }
276    }
277
278    fn sample_minimal() -> Self {
279        Self {
280            action: PrintAction::sample_minimal(),
281            ..Self::sample_full()
282        }
283    }
284}
285
286impl Sample for ActionRecord {
287    fn sample_full() -> Self {
288        Self {
289            id: action_id(),
290            print_id: PrintId::sample_full(),
291            request: ActionRequest::sample_full(),
292            decision: PolicyDecision::Accepted,
293            executed_at: Some(later_instant()),
294            outcome: Some(ExecutionOutcome::Succeeded),
295        }
296    }
297
298    fn sample_minimal() -> Self {
299        Self {
300            request: ActionRequest::sample_minimal(),
301            executed_at: None,
302            outcome: None,
303            ..Self::sample_full()
304        }
305    }
306}
307
308/// The allowed map both the manifest and the envelope carry.
309fn allowed_ranges() -> BTreeMap<Adjustable, Range> {
310    BTreeMap::from([
311        (Adjustable::Feedrate, Range::new(0.5, 1.5)),
312        (Adjustable::ToolTarget { tool: 0 }, Range::new(190.0, 230.0)),
313    ])
314}
315
316impl Sample for JobManifest {
317    fn sample_full() -> Self {
318        Self {
319            file_name: "benchy.gcode".to_owned(),
320            material: "PLA".to_owned(),
321            nozzle_diameter_mm: 0.4,
322            slicer_profile: "0.2mm standard".to_owned(),
323            allowed: allowed_ranges(),
324            metadata: BTreeMap::from([("layer_height_mm".to_owned(), "0.2".to_owned())]),
325        }
326    }
327}
328
329impl Sample for SafetyEnvelope {
330    fn sample_full() -> Self {
331        Self {
332            allowed: allowed_ranges(),
333            actions: BTreeMap::from([(
334                ActorClass::Agent,
335                vec![ActionKind::Pause, ActionKind::SetFeedrateFactor],
336            )]),
337            agent_min_interval_s: 60,
338        }
339    }
340}
341
342impl Sample for EffectiveBounds {
343    fn sample_full() -> Self {
344        Self {
345            allowed: allowed_ranges(),
346        }
347    }
348}
349
350impl Sample for RejectionReason {
351    fn sample_full() -> Self {
352        Self::OutOfBounds {
353            adjustable: Adjustable::Feedrate,
354            requested: 4.0,
355            allowed: Range::new(0.5, 1.5),
356        }
357    }
358
359    fn sample_alternates() -> Vec<Self> {
360        vec![
361            Self::InsufficientFilament {
362                tool: 0,
363                spool_id: spool_id(),
364                spool_name: "Galaxy black".to_owned(),
365                required_g: 120.0,
366                buffer_g: 12.0,
367                remaining_g: 80.0,
368                unverified: Some(UnverifiedReason::sample_full()),
369            },
370            Self::InsufficientFilament {
371                tool: 0,
372                spool_id: spool_id(),
373                spool_name: "Galaxy black".to_owned(),
374                required_g: 120.0,
375                buffer_g: 12.0,
376                remaining_g: 80.0,
377                unverified: None,
378            },
379            Self::UnverifiedSpool {
380                tool: 0,
381                spool_id: spool_id(),
382                spool_name: "Galaxy black".to_owned(),
383                reason: UnverifiedReason::sample_full(),
384            },
385            Self::AnalysisUnavailable {
386                file_name: "benchy.gcode".to_owned(),
387                waited_s: 300,
388            },
389            Self::SpoolRefused {
390                cause: SpoolRefusalCause::sample_full(),
391                message: "spool Galaxy black is retired, so it takes no command".to_owned(),
392            },
393        ]
394    }
395}
396
397impl Sample for SpoolField {
398    fn sample_full() -> Self {
399        Self::GrossG
400    }
401}
402
403impl Sample for SpoolRefusalCause {
404    fn sample_full() -> Self {
405        Self::RetiredSpool {
406            spool_id: spool_id(),
407        }
408    }
409
410    fn sample_minimal() -> Self {
411        Self::DensityRequired {
412            spool_id: None,
413            material: "PEEK".to_owned(),
414        }
415    }
416
417    fn sample_alternates() -> Vec<Self> {
418        vec![
419            Self::UnknownSpool {
420                spool_id: replaced_spool_id(),
421            },
422            Self::NothingToConfirm { tool: 0 },
423            Self::InvalidAdjustmentFigure {
424                field: SpoolField::GrossG,
425                value: -5.0,
426            },
427            Self::TareRequired {
428                spool_id: spool_id(),
429            },
430            Self::DensityRequired {
431                spool_id: Some(spool_id()),
432                material: "PEEK".to_owned(),
433            },
434            Self::MissingField {
435                field: SpoolField::Name,
436            },
437            Self::ConflictingFields {
438                fields: vec![SpoolField::RemainingG, SpoolField::GrossG],
439            },
440            Self::UnknownTool { tool: -1 },
441            Self::NotLoaded {
442                spool_id: spool_id(),
443            },
444            Self::LedgerRefused,
445        ]
446    }
447}
448
449impl Sample for PolicyDecision {
450    fn sample_full() -> Self {
451        Self::Rejected(RejectionReason::sample_full())
452    }
453}
454
455impl Sample for InterventionOutcome {
456    fn sample_full() -> Self {
457        Self::Superseded {
458            by: intervention_id(),
459        }
460    }
461}
462
463impl Sample for Intervention {
464    fn sample_full() -> Self {
465        Self {
466            id: intervention_id(),
467            print_id: PrintId::sample_full(),
468            action_id: action_id(),
469            adjustable: Adjustable::Feedrate,
470            prior_value: Some(1.0),
471            applied_value: 0.8,
472            applied_at: Timestamp::sample_full(),
473            expires_at: later_instant(),
474            restored_at: Some(later_instant()),
475            outcome: InterventionOutcome::Restored,
476        }
477    }
478
479    fn sample_minimal() -> Self {
480        Self {
481            prior_value: None,
482            restored_at: None,
483            outcome: InterventionOutcome::StillActive,
484            ..Self::sample_full()
485        }
486    }
487}
488
489impl Sample for UnverifiedReason {
490    fn sample_full() -> Self {
491        Self::UnchargedPrint {
492            print_id: PrintId::sample_full(),
493        }
494    }
495
496    fn sample_alternates() -> Vec<Self> {
497        vec![
498            Self::UnaccountedPrint {
499                file_name: "benchy.gcode".to_owned(),
500                printed_at: Timestamp::sample_full(),
501            },
502            Self::FilamentChangeUnconfirmed {
503                print_id: PrintId::sample_full(),
504            },
505            Self::FilamentChangeUnconfirmedPosition {
506                print_id: PrintId::sample_full(),
507            },
508            Self::TallyReset {
509                file_name: "benchy.gcode".to_owned(),
510                origin: "local".to_owned(),
511            },
512        ]
513    }
514}
515
516impl Sample for UnverifiedMark {
517    fn sample_full() -> Self {
518        Self {
519            reason: UnverifiedReason::sample_full(),
520            since: Timestamp::sample_full(),
521        }
522    }
523}
524
525impl Sample for UnverifiedMarks {
526    fn sample_full() -> Self {
527        Self::new(vec![
528            UnverifiedMark::sample_full(),
529            UnverifiedMark {
530                reason: UnverifiedReason::FilamentChangeUnconfirmed {
531                    print_id: PrintId::sample_full(),
532                },
533                since: later_instant(),
534            },
535        ])
536        .expect("two marks")
537    }
538}
539
540impl Sample for SpoolTrust {
541    fn sample_full() -> Self {
542        Self::Unverified {
543            marks: UnverifiedMarks::sample_full(),
544        }
545    }
546
547    fn sample_alternates() -> Vec<Self> {
548        vec![Self::Verified]
549    }
550}
551
552impl Sample for SpoolRecord {
553    fn sample_full() -> Self {
554        Self {
555            id: spool_id(),
556            name: "Galaxy black".to_owned(),
557            material: "PLA".to_owned(),
558            color: Some("black".to_owned()),
559            diameter_mm: 1.75,
560            density_g_cm3: 1.24,
561            initial_g: 1_000.0,
562            remaining_g: 742.5,
563            tare_g: Some(250.0),
564            lifecycle: SpoolLifecycle::sample_full(),
565            trust: SpoolTrust::sample_full(),
566            registered_at: Timestamp::sample_full(),
567            updated_at: later_instant(),
568        }
569    }
570
571    fn sample_minimal() -> Self {
572        Self {
573            color: None,
574            tare_g: None,
575            lifecycle: SpoolLifecycle::Shelved,
576            trust: SpoolTrust::Verified,
577            ..Self::sample_full()
578        }
579    }
580
581    fn sample_alternates() -> Vec<Self> {
582        vec![Self {
583            remaining_g: 12.5,
584            lifecycle: SpoolLifecycle::Retired {
585                at: later_instant(),
586            },
587            ..Self::sample_full()
588        }]
589    }
590}
591
592impl Sample for SpoolLifecycle {
593    fn sample_full() -> Self {
594        Self::Loaded { tool: 0 }
595    }
596
597    fn sample_alternates() -> Vec<Self> {
598        vec![
599            Self::Shelved,
600            Self::Retired {
601                at: later_instant(),
602            },
603        ]
604    }
605}
606
607impl Sample for ClearedMark {
608    fn sample_full() -> Self {
609        Self {
610            spool_id: replaced_spool_id(),
611            reason: UnverifiedReason::FilamentChangeUnconfirmed {
612                print_id: PrintId::sample_full(),
613            },
614        }
615    }
616}
617
618impl Sample for LoadedSpool {
619    fn sample_full() -> Self {
620        Self {
621            tool: 0,
622            spool_id: spool_id(),
623        }
624    }
625}
626
627impl Sample for PrintOutcome {
628    fn sample_full() -> Self {
629        Self::Completed
630    }
631}
632
633impl Sample for ChargeMethod {
634    fn sample_full() -> Self {
635        Self::GcodeExtrusion
636    }
637}
638
639impl Sample for ChargeKey {
640    fn sample_full() -> Self {
641        Self::Print {
642            print_id: PrintId::sample_full(),
643            tool: 0,
644            segment: 1,
645        }
646    }
647
648    fn sample_alternates() -> Vec<Self> {
649        vec![Self::Unobserved {
650            origin: "local".to_owned(),
651            file_name: "benchy.gcode".to_owned(),
652            generation: 2,
653            print_number: 7,
654            tool: 0,
655        }]
656    }
657}
658
659impl Sample for FilePosition {
660    fn sample_full() -> Self {
661        Self {
662            bytes: 1_761_607,
663            size_bytes: Some(4_194_304),
664            observed_at: Timestamp::sample_full(),
665        }
666    }
667
668    fn sample_minimal() -> Self {
669        Self {
670            size_bytes: None,
671            ..Self::sample_full()
672        }
673    }
674}
675
676impl Sample for PrintSegmentKey {
677    fn sample_full() -> Self {
678        Self {
679            print_id: PrintId::sample_full(),
680            tool: 0,
681            segment: 1,
682        }
683    }
684}
685
686impl Sample for ChargedFilament {
687    fn sample_full() -> Self {
688        Self {
689            spool_id: spool_id(),
690            grams: 2.98,
691            diameter_mm: 1.75,
692            density_g_cm3: 1.24,
693            remaining_before_g: 745.48,
694            remaining_after_g: 742.5,
695        }
696    }
697}
698
699impl Sample for PendingCharge {
700    fn sample_full() -> Self {
701        Self {
702            charge_key: PrintSegmentKey::sample_full(),
703            length_mm: 1_204.5,
704            method: ChargeMethod::GcodeExtrusion,
705            analysed_length_mm: Some(5_120.0),
706            position: Some(FilePosition::sample_full()),
707            note: Some("fed after the filament change at layer 12".to_owned()),
708            pended_at: later_instant(),
709        }
710    }
711
712    fn sample_minimal() -> Self {
713        Self {
714            method: ChargeMethod::FileFraction,
715            analysed_length_mm: None,
716            position: None,
717            note: None,
718            ..Self::sample_full()
719        }
720    }
721}
722
723impl Sample for PendingTaken {
724    fn sample_full() -> Self {
725        Self {
726            charge_key: ChargeKey::sample_full(),
727            print_id: PrintId::sample_full(),
728        }
729    }
730}
731
732impl Sample for PreflightVerdict {
733    fn sample_full() -> Self {
734        Self::Insufficient
735    }
736}
737
738impl Sample for PreflightSpool {
739    fn sample_full() -> Self {
740        Self {
741            id: spool_id(),
742            name: "Galaxy black".to_owned(),
743        }
744    }
745}
746
747impl Sample for PreflightNeed {
748    fn sample_full() -> Self {
749        Self {
750            required_g: 120.0,
751            buffer_g: 12.0,
752        }
753    }
754}
755
756impl Sample for ShortSpool {
757    fn sample_full() -> Self {
758        Self {
759            spool: PreflightSpool::sample_full(),
760            remaining_g: 80.0,
761            need: PreflightNeed::sample_full(),
762            marks: vec![UnverifiedMark::sample_full()],
763        }
764    }
765
766    fn sample_minimal() -> Self {
767        Self {
768            marks: Vec::new(),
769            ..Self::sample_full()
770        }
771    }
772}
773
774impl Sample for DoubtedSpool {
775    fn sample_full() -> Self {
776        Self {
777            spool: PreflightSpool::sample_full(),
778            remaining_g: 742.5,
779            need: Some(PreflightNeed::sample_full()),
780            marks: UnverifiedMarks::sample_full(),
781        }
782    }
783
784    fn sample_minimal() -> Self {
785        Self {
786            need: None,
787            ..Self::sample_full()
788        }
789    }
790}
791
792impl Sample for UnanalysedSpool {
793    fn sample_full() -> Self {
794        Self {
795            spool: PreflightSpool::sample_full(),
796            remaining_g: 742.5,
797        }
798    }
799}
800
801impl Sample for PreflightObjection {
802    fn sample_full() -> Self {
803        Self::Insufficient(ShortSpool::sample_full())
804    }
805
806    fn sample_minimal() -> Self {
807        Self::NoAnalysis(UnanalysedSpool::sample_full())
808    }
809
810    fn sample_alternates() -> Vec<Self> {
811        vec![
812            Self::Insufficient(ShortSpool::sample_minimal()),
813            Self::UnverifiedSpool(DoubtedSpool::sample_full()),
814        ]
815    }
816}
817
818impl Sample for PreflightToolResult {
819    fn sample_full() -> Self {
820        Self::Insufficient(ShortSpool::sample_full())
821    }
822
823    fn sample_minimal() -> Self {
824        Self::Unchecked
825    }
826
827    fn sample_alternates() -> Vec<Self> {
828        vec![
829            Self::Passed {
830                spool: PreflightSpool::sample_full(),
831                remaining_g: 742.5,
832                need: PreflightNeed::sample_full(),
833            },
834            Self::UnverifiedSpool(DoubtedSpool::sample_minimal()),
835            Self::NoAnalysis(UnanalysedSpool::sample_full()),
836            Self::Overridden {
837                objection: PreflightObjection::sample_full(),
838            },
839            Self::Warned {
840                objection: PreflightObjection::NoAnalysis(UnanalysedSpool::sample_full()),
841            },
842        ]
843    }
844}
845
846impl Sample for PreflightTool {
847    fn sample_full() -> Self {
848        Self {
849            tool: 0,
850            result: PreflightToolResult::sample_full(),
851        }
852    }
853
854    fn sample_minimal() -> Self {
855        Self {
856            tool: 1,
857            result: PreflightToolResult::Unchecked,
858        }
859    }
860}
861
862impl Sample for Preflight {
863    fn sample_full() -> Self {
864        Self {
865            file_name: "benchy.gcode".to_owned(),
866            tools: vec![
867                PreflightTool::sample_full(),
868                PreflightTool::sample_minimal(),
869            ],
870            verdict: PreflightVerdict::Insufficient,
871            checked_at: Timestamp::sample_full(),
872        }
873    }
874}
875
876impl Sample for SpoolCommand {
877    fn sample_full() -> Self {
878        Self::RegisterSpool {
879            name: "Galaxy black".to_owned(),
880            material: "PLA".to_owned(),
881            color: Some("black".to_owned()),
882            diameter_mm: Some(1.75),
883            density_g_cm3: Some(1.24),
884            initial_g: 1_000.0,
885            remaining_g: Some(742.5),
886            tare_g: Some(250.0),
887            reason: "a new spool went on the shelf".to_owned(),
888            actor: Actor::Operator,
889        }
890    }
891
892    fn sample_minimal() -> Self {
893        Self::RegisterSpool {
894            name: "Galaxy black".to_owned(),
895            material: "PLA".to_owned(),
896            color: None,
897            diameter_mm: None,
898            density_g_cm3: None,
899            initial_g: 1_000.0,
900            remaining_g: None,
901            tare_g: None,
902            reason: "a new spool went on the shelf".to_owned(),
903            actor: Actor::Operator,
904        }
905    }
906
907    fn sample_alternates() -> Vec<Self> {
908        let reason = || "the spool on the shelf changed".to_owned();
909        vec![
910            Self::LoadSpool {
911                spool_id: spool_id(),
912                tool: 0,
913                reason: reason(),
914                actor: Actor::Operator,
915            },
916            Self::UnloadSpool {
917                spool_id: spool_id(),
918                reason: reason(),
919                actor: Actor::Operator,
920            },
921            Self::AdjustSpool {
922                spool_id: spool_id(),
923                remaining_g: Some(700.0),
924                gross_g: None,
925                reason: reason(),
926                actor: Actor::Operator,
927            },
928            Self::AdjustSpool {
929                spool_id: spool_id(),
930                remaining_g: None,
931                gross_g: Some(950.0),
932                reason: reason(),
933                actor: Actor::sample_full(),
934            },
935            Self::RetireSpool {
936                spool_id: spool_id(),
937                reason: reason(),
938                actor: Actor::Operator,
939            },
940        ]
941    }
942}