Description
Implement Power as a ValueObject in the measurement module.
Spec: non-negative f64 with unit (W, kW, hp)
Implementation checklist
Implementation detail
Input / Output
Power is a composite value object that carries both a numeric value and a unit.
|
Type |
| Input |
PowerInput { value: f64, unit: PowerUnit } |
| Output |
String — e.g. "1500.0 W", "1.5 kW" |
Define a unit enum in the same file:
PowerUnit must derive Debug, Clone, Copy, PartialEq.
Validation
value must be >= 0.0 and finite.
Extra methods
amount() -> f64
unit() -> PowerUnit
to_watts() -> f64 — convert to watts at call time.
References
Description
Implement
Poweras aValueObjectin themeasurementmodule.Spec: non-negative
f64with unit (W, kW, hp)Implementation checklist
src/measurement/power.rsValueObjecttrait#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]src/measurement/mod.rsandprelude# ExampleblockROADMAP.mdfrom ⬜ to ✅Implementation detail
Input / Output
Poweris a composite value object that carries both a numeric value and a unit.PowerInput { value: f64, unit: PowerUnit }String— e.g."1500.0 W","1.5 kW"Define a unit enum in the same file:
PowerUnitmust deriveDebug, Clone, Copy, PartialEq.Validation
valuemust be >= 0.0 and finite.Extra methods
amount() -> f64unit() -> PowerUnitto_watts() -> f64— convert to watts at call time.References