Skip to main content

printobserver_server/
lib.rs

1//! `printobserver-server`.
2//!
3//! Owns: the long-running service: the HTTP surface the clients call, the
4//! `Obico` ingress the failure detector posts to, the supervision loop's
5//! lifecycle, the composition root that chooses which implementation backs
6//! each port, and the one event kind a restart writes — the startup
7//! reconciliation [`reconcile`] alone records.
8//!
9//! May depend on: `printobserver-types`, the three port crates,
10//! `printobserver-core`, and the implementation crates — it is a composition
11//! root, so naming an implementation is its job rather than a violation.
12//!
13//! # The shape of this crate, in four sentences
14//!
15//! [`config`] is the one configuration file and every value it is validated
16//! against. [`operations`] is the whole public API declared once, and [`api`]
17//! builds the router by folding over it, so the set served and the set declared
18//! cannot come apart. [`ingress`] is `Obico`'s own endpoint, which answers
19//! before its handling completes and inside a bound this repository declares,
20//! and admits a post by its shared secret alone; every route beneath the
21//! versioned prefix admits a request by the operator's credential or a live
22//! supervision turn's alone, and holds it to the identity that credential
23//! authenticated. [`turns`] is where each turn's credential is minted and held.
24//! [`watch`] drives the printer watch, and holds the printer's push channel
25//! and the one command the watch sends. [`server`] is the composition root: the one place an implementation crate is
26//! named, and the only file here that knows there is an `OctoPrint` at all.
27//!
28//! # Images are a path, never bytes
29//!
30//! The server, the command-line program and the supervising agent all run on
31//! the one host by design, so an image answer is an absolute path on this
32//! host's own filesystem. No route this server serves answers image bytes, and
33//! no answer renders or encodes them; see [`wire::ImageAnswer`].
34//!
35//! # Restarting loses nothing
36//!
37//! The store and the session directory are the whole of the state, and
38//! [`reconcile`] is what adopts them on start.
39
40pub mod alignment;
41pub mod api;
42pub mod camera_check;
43pub mod check_images;
44pub mod config;
45pub mod events;
46pub mod ingress;
47pub mod judgements;
48pub mod observation;
49pub mod operations;
50pub mod readiness;
51pub mod reconcile;
52pub mod server;
53pub mod turns;
54pub mod watch;
55pub mod wire;
56
57pub use alignment::{
58    AlignmentFailure, AlignmentJudging, Alignments, CheckedFrame, Judged, Judging, LastCheckImage,
59    PreviousCheck, PrintAlignment,
60};
61pub use api::{Admission, ApiState, BODY_BOUND, Caller, DRAIN_BOUND, SPOOL_RECENT_EVENTS, router};
62pub use camera_check::{CameraCheck, CameraCheckedPayload, CheckCameraQuery, UnavailableReason};
63pub use check_images::{
64    CALIBRATION_STALE, CHECK_IMAGES_DIRECTORY, COMPOSITE_NOTE, PanelImages, PlanAt, Shown,
65    UNSEEN_RISE_BOUND_MM, WHOLE_FRAME_NOTE, WholeFrameReason, WholeFrames, compose_at,
66    composite_note, whole_frame_note,
67};
68pub use config::{
69    ASSETS_DIRECTORY, ApiCredential, ApiSection, ConfigError, ConfigField, ConfigFile,
70    CredentialVerifier, DEFAULT_INGRESS_ANSWER_BOUND_MS, DEFAULT_OBSERVATION_INTERVAL_S,
71    FAN_VOCABULARY, GENERATED_CREDENTIAL_BYTES, IngressSection, OBICO_POSTING_TIMEOUT_MS,
72    OctoprintSection, REDACTED, SKILL_INSTALL, ServerConfig, SharedSecret, SignInConfig,
73    SpoolsSection, SupervisorSection, VERIFIER_PREFIX, plainly_written,
74};
75pub use events::{DEFAULT_EVENTS_LIMIT, MAX_EVENTS_LIMIT, MAX_EVENTS_WAIT_S, Stored};
76pub use ingress::{IngressState, QUEUE_DEPTH, TOKEN_HEADER, TOKEN_PARAM};
77pub use judgements::{
78    AlignmentJudgedVerdict, CameraViewJudgedPayload, CameraViewRefitPayload,
79    CheckImageChangedPayload, FirstLayerAlignmentJudgedPayload,
80};
81pub use operations::{
82    Answer, BED_CLEAR, BESIDE_THE_ACTIONS, CAMERA_CHECK_IMAGE_FIELD, CHECK_CAMERA, CHECK_HARNESS,
83    COMMAND_TAG, CONTEXT_IMAGE_PATH_FIELD, Declared, Effect, IMAGE_PATH_FIELD, INGRESS_PATH,
84    Located, MEDIA_TYPE, Method, OPERATIONS, Operation, PRINTER_LOOK, Parameter, RECHECK_CAMERA,
85    RECHECK_FRAME_PATH_FIELD, RECOVERY_STATUS, RecoveryActionKind, SpoolCommandKind,
86    VERSION_PREFIX, ValueKind, command_for, operation, printer_wide_of,
87};
88/// The longest wait one look takes, which a refusal's advice is held to.
89pub use printobserver_core::MAX_LOOK_WAIT_S;
90/// The harness identities this program can sign in, as the adapter declares
91/// them: the command-line program reads the table through this crate, which is
92/// the one edge it has to the adapter.
93pub use printobserver_oneharness::{HARNESS_DIRECTORY, HarnessSignIn, SIGN_INS};
94pub use readiness::{
95    EXPECTED_WORDS, HarnessCheck, HarnessReadiness, HarnessSignedIn, HarnessTurn, SIGN_IN_COMMAND,
96    STATUS_BOUND, check_prompt,
97};
98pub use reconcile::{
99    ReconcileStores, Reconciliation, StartupOutcome, StartupReconciliationPayload,
100    UnobservedAccounting, overdue, reconcile,
101};
102pub use server::{
103    API_CREDENTIAL_FILE, API_CREDENTIAL_VERIFIER_FILE, CLIENT_CONFIG_FILE, CONTEXT_PROGRAM,
104    CREDENTIAL_ISSUE, CREDENTIAL_VERIFIER, OperatorCredential, PROMPT_FILE, Ports, Running,
105    SCHEMA_FILE, Server, StartError, TURN_PROMPT, agent_config, agent_config_with, context_command,
106    operator_credential, plaintext_credential_warning,
107};
108pub use turns::{GENERATED_TURN_CREDENTIAL_BYTES, TurnBinding, TurnCredentials};
109pub use wire::{
110    ActionAnswer, ActionBody, BedClearAnswer, BedClearBody, BodyRefusal, ContextAnswer,
111    ErrorAnswer, EventsAnswer, HistoryAnswer, ImageAnswer, IngressAnswer, LookAnswer,
112    ManifestAnswer, ManifestBody, PreflightAnswer, PrintEnded, PrintsAnswer, RecheckCameraAnswer,
113    RecoveryAnswer, RecoveryStatusAnswer, SpoolAnswer, SpoolCommandAnswer, SpoolsAnswer,
114    StatusAnswer, TimelineAnswer, at_a_glance, claimed_actor, reason_of, recovery_of,
115    spool_command_of,
116};