Skip to main content

printobserver_types/
context.rs

1//! The one aggregate a caller and the agent both read.
2
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6use crate::event::EventRecord;
7use crate::image::ImageRef;
8use crate::intervention::Intervention;
9use crate::manifest::JobManifest;
10use crate::policy::EffectiveBounds;
11use crate::print::PrintRecord;
12use crate::printer::{JobSnapshot, PrinterSnapshot};
13
14/// Everything a supervision turn is given about one print.
15#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
16#[serde(deny_unknown_fields)]
17pub struct PrintContext {
18    /// The print itself.
19    pub print: PrintRecord,
20    /// The printer, when a snapshot could be taken.
21    #[serde(default, skip_serializing_if = "Option::is_none")]
22    pub printer: Option<PrinterSnapshot>,
23    /// The job, when a snapshot could be taken.
24    #[serde(default, skip_serializing_if = "Option::is_none")]
25    pub job: Option<JobSnapshot>,
26    /// The manifest, when the print has one.
27    #[serde(default, skip_serializing_if = "Option::is_none")]
28    pub manifest: Option<JobManifest>,
29    /// The limits in force, so that the agent can see them before it asks.
30    pub bounds: EffectiveBounds,
31    /// The interventions still active.
32    pub interventions: Vec<Intervention>,
33    /// A bounded list of this print's events, newest first.
34    pub recent_events: Vec<EventRecord>,
35    /// The most recent image, when there is one.
36    #[serde(default, skip_serializing_if = "Option::is_none")]
37    pub latest_image: Option<ImageRef>,
38}