Description
Implement Pressure as a ValueObject in the measurement module.
Spec: non-negative f64 with unit (Pa, bar, psi)
Implementation checklist
Implementation detail
Input / Output
Pressure is a composite value object that carries both a numeric value and a unit.
|
Type |
| Input |
PressureInput { value: f64, unit: PressureUnit } |
| Output |
String — e.g. "101325.0 Pa", "1.01 bar" |
Define a unit enum in the same file:
PressureUnit { Pa, Bar, Psi }
PressureUnit must derive Debug, Clone, Copy, PartialEq.
Validation
value must be >= 0.0 and finite.
Extra methods
amount() -> f64
unit() -> PressureUnit
to_pascals() -> f64 — convert to Pa at call time.
References
Description
Implement
Pressureas aValueObjectin themeasurementmodule.Spec: non-negative
f64with unit (Pa, bar, psi)Implementation checklist
src/measurement/pressure.rsValueObjecttrait#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]src/measurement/mod.rsandprelude# ExampleblockROADMAP.mdfrom ⬜ to ✅Implementation detail
Input / Output
Pressureis a composite value object that carries both a numeric value and a unit.PressureInput { value: f64, unit: PressureUnit }String— e.g."101325.0 Pa","1.01 bar"Define a unit enum in the same file:
PressureUnitmust deriveDebug, Clone, Copy, PartialEq.Validation
valuemust be >= 0.0 and finite.Extra methods
amount() -> f64unit() -> PressureUnitto_pascals() -> f64— convert to Pa at call time.References