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