Skip to main content

printobserver_types/
printer_state.rs

1//! The state a source reports a printer or a print to be in.
2//!
3//! Two ports speak it: the printer port's snapshots report it, and the
4//! supervisor port's turn situation hands it to the agent. Neither port may
5//! depend on the other, so the one vocabulary both read is declared here, and
6//! `printobserver-printer-api` re-exports it where its own users name it. The
7//! supervision domain's print record carries the same state.
8
9use schemars::JsonSchema;
10use serde::{Deserialize, Serialize};
11
12use crate::contract::Sample;
13
14/// The state a source reports a printer or a print to be in.
15///
16/// The `unknown` arm exists so that a state nobody anticipated is recorded
17/// carrying the source's own word for it rather than lost.
18#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
19#[serde(rename_all = "snake_case", deny_unknown_fields)]
20// llmlint: ignore[code_lands_in_the_domain_that_owns_it] suppressions.toml has the reason.
21pub enum PrinterState {
22    /// Connected and idle.
23    Operational,
24    /// Printing, but paused.
25    Paused,
26    /// Printing.
27    Printing,
28    /// Cancelling a print.
29    Cancelling,
30    /// In an error state.
31    Error,
32    /// Not reachable.
33    Offline,
34    /// A state this vocabulary does not name, in the source's own word for it.
35    Unknown(String),
36}
37
38impl Sample for PrinterState {
39    fn sample_full() -> Self {
40        Self::Printing
41    }
42}