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, and the composition root that chooses which implementation backs
6//! each port.
7//!
8//! May depend on: `printobserver-types`, the four port crates,
9//! `printobserver-core`, and the implementation crates — it is a composition
10//! root, so naming an implementation is its job rather than a violation.
11//!
12//! # The shape of this crate, in four sentences
13//!
14//! [`config`] is the one configuration file and every value it is validated
15//! against. [`operations`] is the whole public API declared once, and [`api`]
16//! builds the router by folding over it, so the set served and the set declared
17//! cannot come apart. [`ingress`] is `Obico`'s own endpoint, which answers
18//! before its handling completes and inside a bound this repository declares.
19//! [`server`] is the composition root: the one place an implementation crate is
20//! named, and the only file here that knows there is an `OctoPrint` at all.
21//!
22//! # Images are a path, never bytes
23//!
24//! The server, the command-line program and the supervising agent all run on
25//! the one host by design, so an image answer is an absolute path on this
26//! host's own filesystem. No route this server serves answers image bytes, and
27//! no answer renders or encodes them; see [`wire::ImageAnswer`].
28//!
29//! # Restarting loses nothing
30//!
31//! The store and the session directory are the whole of the state, and
32//! [`reconcile`] is what adopts them on start.
33
34pub mod api;
35pub mod config;
36pub mod ingress;
37pub mod operations;
38pub mod reconcile;
39pub mod server;
40pub mod wire;
41
42pub use api::{ApiState, router};
43pub use config::{
44    ASSETS_DIRECTORY, ConfigError, ConfigField, ConfigFile, DEFAULT_INGRESS_ANSWER_BOUND_MS,
45    FAN_VOCABULARY, IngressSection, OBICO_POSTING_TIMEOUT_MS, OctoprintSection, REDACTED,
46    ServerConfig, SharedSecret, SupervisorSection,
47};
48pub use ingress::{IngressState, QUEUE_DEPTH, TOKEN_HEADER, TOKEN_PARAM};
49pub use operations::{
50    Answer, BESIDE_THE_ACTIONS, CONTEXT_IMAGE_PATH_FIELD, Declared, Effect, IMAGE_PATH_FIELD,
51    INGRESS_PATH, Located, MEDIA_TYPE, Method, OPERATIONS, Operation, Parameter, VERSION_PREFIX,
52    ValueKind, operation,
53};
54pub use reconcile::{Reconciliation, overdue, reconcile};
55pub use server::{
56    CLIENT_CONFIG_FILE, CONTEXT_PROGRAM, PROMPT_FILE, Ports, Running, SCHEMA_FILE, SKILL_FILE,
57    Server, StartError, TURN_PROMPT, context_command,
58};
59pub use wire::{
60    ActionAnswer, ActionBody, BodyRefusal, ContextAnswer, ErrorAnswer, HistoryAnswer, ImageAnswer,
61    IngressAnswer, ManifestAnswer, ManifestBody, StatusAnswer, reason_of,
62};