pub struct Current(/* private fields */);Expand description
A finite, non-negative electric current in amperes.
Implementations§
Source§impl Current
impl Current
Sourcepub fn amperes(value: f64) -> Result<Self, ElectricError>
pub fn amperes(value: f64) -> Result<Self, ElectricError>
Creates a current magnitude in amperes.
Sourcepub const fn as_amperes(self) -> f64
pub const fn as_amperes(self) -> f64
Returns the current magnitude in amperes.
Examples found in repository?
examples/dc_circuit.rs (line 16)
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 Current
Source§impl PartialOrd for Current
impl PartialOrd for Current
impl StructuralPartialEq for Current
Auto Trait Implementations§
impl Freeze for Current
impl RefUnwindSafe for Current
impl Send for Current
impl Sync for Current
impl Unpin for Current
impl UnsafeUnpin for Current
impl UnwindSafe for Current
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