Expand description
Transmit / receive power type.
Power wraps a uom SI watt quantity with ham-radio-centric
constructors and a smart Display that selects the most readable unit.
§Display formats
The default formatter ({}) uses watts. The alternate formatter ({:#}) selects milliwatts,
watts, or kilowatts based on the value:
use rfham_core::power::Power;
assert_eq!(Power::watts(5.0).to_string(), "5 W");
assert_eq!(format!("{:#}", Power::watts(5.0)), "5 watts");
assert_eq!(format!("{:#}", Power::milliwatts(0.5)), "0.5 milliwatts"); // < 0.001 W
assert_eq!(format!("{:#}", Power::kilowatts(1.5)), "1.5 kilowatts");§Examples
use rfham_core::power::Power;
// Derived from DC circuit: P = V × I
let p = Power::from_dc_circuit(13.8, 10.0); // 13.8 V × 10 A
assert!((p.value() - 138.0).abs() < 1e-9);
// Derived from AC circuit: P = V × I × PF
let p = Power::from_ac_circuit(120.0, 5.0, 0.85);
assert!((p.value() - 510.0).abs() < 1e-9);