Skip to main content

Module server

Module server 

Source
Expand description

The embedded HTTP server — a monitoring + control API (axum) and, when the dashboard feature is on, the React SPA (embedded via rust-embed). Behind the server feature; another consumer of the library, like the CLI.

Auth: reads are always open; writes (control) are gated by an optional password (None = open). The LAN access code stays server-side and never reaches a client.

Re-exports§

pub use api::AppState;
pub use api::FakeSource;
pub use api::PrinterSource;
pub use camera::CameraSource;
pub use camera::ExternalCamera;
pub use camera::LiveCamera;
pub use camera::NoCamera;
pub use control::Controller;
pub use control::FakeController;
pub use control::LiveController;
pub use files::FakeFiles;
pub use files::FileStore;
pub use files::LiveFiles;
pub use live::LiveSource;
pub use start::FakeStarter;
pub use start::LiveStarter;
pub use start::Starter;

Modules§

api
The axum router, app state, the printer-source seam + fake source, and the HTTP API (reads + control).
camera
The built-in (printer chamber) camera seam for the server — distinct from the external IP-camera proxy, which is just a URL on super::AppState. Live mode grabs a JPEG over TCP:6000 (see crate::camera); fake / no-target mode has no built-in camera. Abstracted as a trait so the server stays testable without a real printer.
control
Control actions (the write side of the API) and the controller seam.
files
File access (the printer’s storage) — list + upload, behind a seam so the API is testable without a printer: tests and --fake use FakeFiles; live mode uses LiveFiles (FTPS). Listing is a read (open); upload is a write (password-gated). Both are blocking — call from spawn_blocking.
live
The live printer source: bridges the blocking LAN MQTT monitor loop into a watch channel so the dashboard can stream the real device status the same way it streams the fake one.
start
Starting a print (the write side, separate from simple control because it carries file/plate/AMS parameters and needs a fresh MQTT connection). Behind a seam so the API is testable: tests/--fake use FakeStarter; live mode uses LiveStarter (project_file/gcode_file + verify).
stream_record
Recording a camera’s MJPEG stream to disk for the “plain” timelapse. For a camera that exposes a real /stream, this captures the actual continuous video instead of time-sampling /snapshot. The copy + reconnect logic is pure (the stream opener and the sink are injected), so it’s unit-tested without a network: tests feed canned readers and a Vec sink, and drive the cancel signal.
timelapse
Serve-internal per-layer timelapse capture. The dashboard’s single MQTT connection already streams PrinterStatus over a watch channel, so the capture runs inside bambu serve off that feed — no second printer connection (the A1 mini allows only one) and the lowest possible latency.

Structs§

ServeOpts
Options for serve.

Functions§

serve
Run the server (blocking; owns its own multi-thread runtime).