Expand description
§use-electricity
Electricity-specific scalar helpers for RustUse.
§Install
[dependencies]
use-electricity = "0.0.1"§Foundation
use-electricity provides small helpers for charge, current, voltage, resistance, conductance, electrical power, electrical energy, Coulomb force, and simple series or parallel resistance calculations.
Inputs are expected to be SI-style numeric values:
- coulombs for charge
- amperes for current
- seconds for time
- volts for voltage
- ohms for resistance
- siemens for conductance
- watts for power
- joules for energy
- meters for distance
- newtons for force
The crate does not define a full unit system. More general units and constants belong in the top-level use-units and use-constants sets.
§Example
use use_electricity::{ElectricalLoad, power_from_voltage_current, voltage};
assert_eq!(voltage(2.0, 5.0), Some(10.0));
assert_eq!(power_from_voltage_current(10.0, 2.0), Some(20.0));
let load = ElectricalLoad::new(10.0, 5.0).expect("valid load");
assert_eq!(load.power(), Some(20.0));§When to use directly
Choose use-electricity when you need reusable scalar electricity formulas without bringing in a broader circuit or unit system.
§Scope
- APIs stay
f64-first and deliberately small. - Circuit analysis is intentionally minimal and limited to simple scalar helpers.
- Broader constants, waveform modeling, signal processing, and measurement systems are out of scope.
§Status
use-electricity is a pre-1.0 crate with a deliberately small API.
Electricity-specific scalar helpers.
Modules§
Structs§
- Electrical
Load - A simple electrical load described by voltage and resistance.
Constants§
- COULOMB_
CONSTANT - Coulomb’s constant for electrostatic force calculations.
Functions§
- charge_
from_ current_ time - Computes electric charge from current and elapsed time.
- conductance
- Computes conductance from resistance.
- coulomb_
force - Computes electrostatic force using Coulomb’s law.
- current
- Computes current from voltage and resistance using Ohm’s law.
- current_
from_ charge_ time - Computes current from electric charge and elapsed time.
- energy_
from_ power_ time - Computes electrical energy from power and elapsed time.
- energy_
from_ voltage_ charge - Computes electrical energy from voltage and charge.
- parallel_
resistance - Computes the total resistance for resistors in parallel.
- power_
from_ current_ resistance - Computes electrical power from current and resistance.
- power_
from_ voltage_ current - Computes electrical power from voltage and current.
- power_
from_ voltage_ resistance - Computes electrical power from voltage and resistance.
- resistance
- Computes resistance from voltage and current using Ohm’s law.
- resistance_
from_ conductance - Computes resistance from conductance.
- series_
resistance - Computes the total resistance for resistors in series.
- voltage
- Computes voltage from current and resistance using Ohm’s law.