Skip to content

Add Power (measurement) #64

@vhrcgcom

Description

@vhrcgcom

Description

Implement Power as a ValueObject in the measurement module.

Spec: non-negative f64 with unit (W, kW, hp)

Implementation checklist

  • Create src/measurement/power.rs
  • Implement ValueObject trait
  • Add #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
  • Export from src/measurement/mod.rs and prelude
  • Unit tests: valid input · empty input · invalid format · normalisation
  • Doc comment with # Example block
  • Update status in ROADMAP.md from ⬜ to ✅

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 { W, Kw, Hp }

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions