pub struct Power(/* private fields */);Expand description
A finite, non-negative power in watts.
Implementations§
Source§impl Power
impl Power
Sourcepub fn watts(value: f64) -> Result<Self, ElectricError>
pub fn watts(value: f64) -> Result<Self, ElectricError>
Creates a power magnitude in watts.
Sourcepub fn from_voltage_and_current(
voltage: Voltage,
current: Current,
) -> Result<Self, ElectricError>
pub fn from_voltage_and_current( voltage: Voltage, current: Current, ) -> Result<Self, ElectricError>
Calculates ideal DC power as voltage multiplied by current.
Sourcepub const fn as_watts(self) -> f64
pub const fn as_watts(self) -> f64
Returns power in watts.
Examples found in repository?
examples/dc_circuit.rs (line 17)
5fn main() -> Result<(), force_electric::ElectricError> {
6 let point = DcOperatingPoint::from_voltage_and_resistance(
7 Voltage::volts(12.0)?,
8 Resistance::ohms(6.0)?,
9 )?;
10 let energy = Energy::from_power_over(point.power(), Duration::hours(3.0)?)?;
11
12 let resistors = [Resistance::ohms(100.0)?, Resistance::ohms(100.0)?];
13 let series = series_resistance(&resistors)?;
14 let parallel = parallel_resistance(&resistors)?;
15
16 println!("current: {:.2} A", point.current().as_amperes());
17 println!("power: {:.2} W", point.power().as_watts());
18 println!("energy over 3 h: {:.2} Wh", energy.as_watt_hours());
19 println!("series resistance: {:.2} ohm", series.as_ohms());
20 println!("parallel resistance: {:.2} ohm", parallel.as_ohms());
21
22 Ok(())
23}Trait Implementations§
impl Copy for Power
Source§impl PartialOrd for Power
impl PartialOrd for Power
impl StructuralPartialEq for Power
Auto Trait Implementations§
impl Freeze for Power
impl RefUnwindSafe for Power
impl Send for Power
impl Sync for Power
impl Unpin for Power
impl UnsafeUnpin for Power
impl UnwindSafe for Power
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more