printobserver_types/lib.rs
1//! `printobserver-types`.
2//!
3//! Owns: the shared domain vocabulary every other crate speaks — printer and
4//! job identity, observed printer state, vision observations, supervisory
5//! decisions, and their serialized forms. It holds data and total functions
6//! over that data, never I/O.
7//!
8//! May depend on: no crate of this workspace. It is the root of the graph, so a
9//! type it does not hold is a type the rest of the workspace cannot agree on.
10//!
11//! # One authoritative source per restated fact
12//!
13//! The types here are declared once and imported by every consumer rather than
14//! re-declared. The JSON Schemas the clients and the agent's structured answer
15//! are validated against are **generated from these types** by the
16//! `printobserver-types:schemas` graph target, which the gate runs: a schema
17//! checked into `schemas/` that no longer matches what these types generate
18//! fails that target. Nothing transcribes a schema by hand, and nothing
19//! restates a field.
20//!
21//! [`contract`] is where that generation reads the declared set from: it is
22//! this crate's own claim about which types it declares and what a canonical
23//! value of each looks like.
24//!
25//! # The representations, stated once
26//!
27//! * **Identifiers.** Every identifier this system mints is a UUID version 7,
28//! minted by the store, held as a distinct newtype per record, and serialized
29//! as its lowercase hyphenated string. See [`ids`].
30//! * **Numbers.** Every temperature, factor, multiplier, percentage and
31//! fraction is a 64-bit float. Every byte count and every integer identifier
32//! an external system supplies is a 64-bit signed integer. Every duration is
33//! whole seconds as a 64-bit signed integer.
34//! * **Timestamps.** Every timestamp is an instant in UTC, serialized as an RFC
35//! 3339 string with a zero offset. See [`Timestamp`].
36//! * **Optionality.** An optional field absent means *the source did not report
37//! it*, and is never rendered as a zero, an empty string, or a default.
38//! Absent serializes as absent and parses back as absent.
39//! * **Declared ranges.** A numeric field this crate declares a range for is
40//! typed [`Reported<f64>`]. See [`reported`] for the whole rule, including
41//! why a non-finite value is out of range and why one is refused on emission.
42//!
43//! # Why `serde`, `schemars` and `serde_json` are re-exported
44//!
45//! The four port crates depend on this crate and on nothing else, and each of
46//! them declares request and answer shapes that cross a process boundary and so
47//! must derive the same traits these types derive. They reach the derive macros
48//! through [`serde`], [`schemars`] and [`serde_json`] here rather than by
49//! declaring a dependency of their own.
50
51pub mod action;
52pub mod adjustable;
53pub mod assessment;
54pub mod context;
55pub mod contract;
56pub mod event;
57pub mod file_name;
58pub mod ids;
59pub mod image;
60pub mod intervention;
61pub mod manifest;
62pub mod obico;
63pub mod policy;
64pub mod print;
65pub mod printer;
66pub mod raw;
67pub mod reported;
68pub mod session;
69pub mod timestamp;
70
71pub use action::{
72 AcknowledgementDisposition, ActionKind, ActionRecord, ActionRequest, Actor, ActorClass,
73 ExecutionOutcome, PrintAction,
74};
75pub use adjustable::{Adjustable, AdjustableError};
76pub use assessment::{AgentAssessment, Confidence};
77pub use context::PrintContext;
78pub use contract::{
79 RANGED_FIELDS, RangedField, Sample, TypeContract, WireField, declared, wire_fields,
80};
81pub use event::{
82 ActionExecutedPayload, ActionRejectedPayload, ActionRequestedPayload, AgentAssessmentPayload,
83 EventKind, EventPayload, EventRecord, EventSource, InterventionExpiredPayload,
84 MalformedExternalEventPayload, ObicoFailureAlertPayload, ObicoNotificationType,
85 ObicoPrinterNotificationPayload, OperatorAcknowledgementPayload, PortFailurePayload,
86 PortFailureSite, StartupOutcome, StartupReconciliationPayload, SupervisionSessionClosedPayload,
87 SupervisionSessionOpenedPayload,
88};
89pub use file_name::{FileName, FileNameError, FileNameRefusal, SEPARATORS};
90pub use ids::{ActionId, EventId, IdentifierError, ImageId, InterventionId, PrintId};
91pub use image::{ImageRecord, ImageRef};
92pub use intervention::{Intervention, InterventionOutcome};
93pub use manifest::JobManifest;
94pub use obico::{
95 ObicoEventType, ObicoFailureAlert, ObicoFailureEvent, ObicoFailureEventType,
96 ObicoNotificationEvent, ObicoPrintInfo, ObicoPrinterInfo, ObicoPrinterNotification,
97 ObicoTimestamp,
98};
99pub use policy::{EffectiveBounds, PolicyDecision, RejectionReason, SafetyEnvelope};
100pub use print::{ManifestNarrowing, PrintRecord};
101pub use printer::{HeaterSnapshot, JobSnapshot, PrinterSnapshot, PrinterState};
102pub use raw::RawBytes;
103pub use reported::{
104 COMPLETION_RANGE, FAN_PERCENT_RANGE, FEEDRATE_FACTOR_RANGE, FLOWRATE_FACTOR_RANGE,
105 HEATER_ACTUAL_C_RANGE, HEATER_OFFSET_C_RANGE, HEATER_TARGET_C_RANGE, Range, Reported,
106};
107pub use session::{SessionPhase, SupervisionSession};
108pub use timestamp::{Timestamp, TimestampError};
109
110pub use schemars;
111pub use serde;
112pub use serde_json;