Skip to main content

Module reported

Module reported 

Source
Expand description

Reported numbers, and the plausibility ranges this crate declares for them.

A numeric field this crate declares a range for is typed Reported<f64>, which serializes as an object carrying a value and a boolean out_of_range that is true exactly when the reported value is non-finite or lies outside the range this crate declares for that field. A value outside the range is carried through as reported with that flag set, never coerced, never clamped and never dropped.

The non-finite half of that definition is deliberate, because f64 admits inhabitants an ordinary range comparison answers wrongly. NaN compares neither below a minimum nor above a maximum, so value < min || value > max would report the most implausible reading this type can hold as a plausible one; the two infinities lie outside every finite range. All three are what a disconnected thermistor or a division by a zero-valued reading produces, which is exactly the class the flag exists to carry, so all three are out_of_range.

On the wire the type is closed instead: the JSON number grammar denotes no non-finite value, so a Reported<f64> never arrives by parse carrying one, and this crate refuses a non-finite value on emission rather than taking the serializer’s own default of emitting null — which would parse back as a field the source did not report and turn an implausible reading into no reading at all.

These are validity ranges on what a printer can plausibly report, and they are not the operator’s safety envelope. A reading outside one of them says the source reported something implausible — a disconnected thermistor, a firmware that answers in another unit. What an actor is allowed to ask for is SafetyEnvelope, which is server configuration and is narrower by orders of magnitude; nothing in this crate reads these ranges as a bound on an action, and the two are never intersected, compared or substituted for one another.

Structs§

Range
An inclusive pair of 64-bit floats.
Reported
A value a source reported, carrying whether it is outside the range this crate declares for the field it was reported in.

Constants§

COMPLETION_RANGE
The plausibility range of JobSnapshot::completion, as a fraction.
FAN_PERCENT_RANGE
The plausibility range of PrinterSnapshot::fan_percent, in percent.
FEEDRATE_FACTOR_RANGE
The plausibility range of PrinterSnapshot::feedrate_factor.
FLOWRATE_FACTOR_RANGE
The plausibility range of PrinterSnapshot::flowrate_factor.
HEATER_ACTUAL_C_RANGE
The plausibility range of HeaterSnapshot::actual_c, in degrees Celsius.
HEATER_OFFSET_C_RANGE
The plausibility range of HeaterSnapshot::offset_c, in degrees Celsius.
HEATER_TARGET_C_RANGE
The plausibility range of HeaterSnapshot::target_c, in degrees Celsius.