Skip to main content

Module reported

Module reported 

Source
Expand description

Reported numbers, and the rule a plausibility range flags them under.

A numeric field a domain 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 declared 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 ranges themselves are the declaring domain’s — the printer port’s, for what a printer reports — and this module holds the representation and deserialize_ranged, the one reading of a field against its range, rather than any range.

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.

A plausibility range is a validity range on what a source can plausibly report, and it is not the operator’s safety envelope. A reading outside one 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 the supervision domain’s SafetyEnvelope, declared in printobserver-core as server configuration and narrower by orders of magnitude; nothing reads a plausibility range 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.

Functions§

deserialize_ranged
Read an optional reported value, refusing a flag that disagrees with the value under the range declared for the field it was read in.