Expand description
printobserver-printer-api.
Owns: the port the physical printer speaks through — the trait for reading
printer and job state and for asking the machine to do one of the bounded
things the action vocabulary names, plus that port’s own error type — and
the printer domain’s vocabulary: the state a printer reports (state,
declared in printobserver-types and re-exported here), the closed set of
things an adjustment may change (adjustable), the snapshots those reads
answer (snapshot), what the printer knows of the files it holds and the
filament they use ([file]) and the plausibility ranges their reported
numbers are read against (ranges). A change to what a
printer reports edits this crate and the adapters behind it, and nothing
central.
May depend on: printobserver-types only. A port that named an
implementation would stop being a port.
§What this port does not expose
There is no method that accepts a command string, and that absence is the
contract rather than an omission: no method here admits a byte sequence at
all, and the only string anywhere in the closure reachable from a method’s
parameters is the one FileName wraps, which only
PrinterPort::start and the five reads of one file —
PrinterPort::file_facts, PrinterPort::filament_types,
PrinterPort::extruded_to, PrinterPort::printed_extent and
PrinterPort::read_gcode — take. Every value a method takes is already
bounded by the time it arrives: policy has ruled on it before it gets here.
PrinterPort::read_gcode takes a GcodeSink beside the file name, and
that is no exception either: the sink is where the file’s bytes go from
the printer, a piece at a time, so nothing reaches a machine through it.
PrinterPort::send_command is no exception to that: what it takes is a
PrinterCommand, a closed vocabulary each adapter renders to its own
line, so the set of lines that can reach a machine through it is the set of
variants declared here and nothing a caller writes.
§What the printer pushes
PrinterPort::push_events opens the printer’s own push channel and
answers what it pushes (push): a reset, an error it reported, and each
line of its terminal. Those are the facts a poll of the printer’s state
cannot see — a reset while idle changes nothing a read reports — and the
stream ends when the channel drops, so a reader knows when it is reading
nothing.
§Why the methods answer a boxed future
Every method is asynchronous, and the trait is dyn-compatible and shareable
across threads, because the supervision core holds every port behind
Arc<dyn Port>. An async fn in a trait is not dyn-compatible, so each
method answers a BoxFuture instead: the same asynchrony, in the one
shape a trait object can carry.
Re-exports§
pub use adjustable::Adjustable;pub use adjustable::AdjustableError;pub use file::FileFacts;pub use file::FilePrint;pub use file::Footprint;pub use file::GcodeSink;pub use file::PrintedExtent;pub use file::ToolFilament;pub use push::AxisPosition;pub use push::BoxStream;pub use push::HomeAxes;pub use push::PrinterCommand;pub use push::PrinterErrorReason;pub use push::PrinterPush;pub use push::Stream;pub use ranges::COMPLETION_RANGE;pub use ranges::FAN_PERCENT_RANGE;pub use ranges::FEEDRATE_FACTOR_RANGE;pub use ranges::FLOWRATE_FACTOR_RANGE;pub use ranges::HEATER_ACTUAL_C_RANGE;pub use ranges::HEATER_OFFSET_C_RANGE;pub use ranges::HEATER_TARGET_C_RANGE;pub use ranges::RANGED_FIELDS;pub use ranges::RangedField;pub use snapshot::ErrorSource;pub use snapshot::HeaterSnapshot;pub use snapshot::JobError;pub use snapshot::JobSnapshot;pub use snapshot::PrinterSnapshot;
Modules§
- adjustable
- The closed set of things an adjustment may change.
- file
- What a printer knows of the files it holds, and of the filament they use.
- push
- What a printer pushes on its own, and the closed set of commands it may be sent.
- ranges
- The plausibility ranges the printer port declares for what a printer reports.
- snapshot
- Normalized observations of a printer and of the job it is running.
- state
- The state a source reports a printer or a print to be in.
Enums§
- Printer
Error - Why the printer did not do what it was asked.
- Printer
State - The state a source reports a printer or a print to be in.
Traits§
- Printer
Port - The port the physical printer speaks through.
Type Aliases§
- BoxFuture
- A future this port’s methods answer with, in the one shape a trait object can carry.