Skip to main content

Crate use_reaction

Crate use_reaction 

Source
Expand description

§use-reaction

Small chemical reaction representation primitives for RustUse chemistry crates.

use-reaction represents reaction equations, reaction-side terms, arrows, conditions, catalysts, solvents, and lightweight classification labels. It stays structural and avoids balancing, reaction solving, kinetics, thermodynamics, equilibrium calculations, mechanisms, electrochemistry, reaction databases, and external data fetching.

§What this crate provides

ItemPurpose
ChemicalReactionReaction value with equation, conditions, and kinds
ReactionEquationReactants, products, and arrow
ReactionTermFormula-backed term with stoichiometric coefficient
ReactantReactant-side term wrapper
ProductProduct-side term wrapper
ReactionArrowForward, reverse, reversible, and equilibrium arrow
ReactionDirectionLightweight direction label
ReactionConditionTemperature, pressure, catalyst, solvent, and labels
ReactionConditionSetOrdered reaction condition collection
CatalystValidated catalyst descriptor
SolventValidated solvent descriptor
ReactionKindLightweight reaction classification label
ReactionValidationErrorStructured construction and validation errors

§Installation

[dependencies]
use-reaction = "0.1.0"

§Quick Examples

§Create a simple reaction

use use_reaction::{ChemicalReaction, ReactionArrow, ReactionTerm};

let reaction = ChemicalReaction::new()
    .with_reactant(ReactionTerm::new("H2".parse()?).with_coefficient(2)?)
    .with_reactant(ReactionTerm::new("O2".parse()?))
    .with_product(ReactionTerm::new("H2O".parse()?).with_coefficient(2)?)
    .with_arrow(ReactionArrow::Forward);

assert_eq!(reaction.to_string(), "2H2 + O2 -> 2H2O");
reaction.validate()?;

§Attach reaction labels

use use_reaction::{ChemicalReaction, ReactionCondition, ReactionKind, ReactionTerm};

let reaction = ChemicalReaction::new()
    .with_reactant(ReactionTerm::new("CH4".parse()?))
    .with_reactant(ReactionTerm::new("O2".parse()?).with_coefficient(2)?)
    .with_product(ReactionTerm::new("CO2".parse()?))
    .with_product(ReactionTerm::new("H2O".parse()?).with_coefficient(2)?)
    .with_kind(ReactionKind::Combustion)
    .with_condition(ReactionCondition::Heat);

assert_eq!(reaction.to_string(), "CH4 + 2O2 -> CO2 + 2H2O");
assert_eq!(reaction.kinds(), &[ReactionKind::Combustion]);
assert_eq!(reaction.conditions().to_string(), "heat");

§Scope

  • Represents reaction equations, reactants, products, arrows, conditions, catalysts, solvents, energy labels, and classification labels.
  • Uses use-chemical-formula for chemical formula primitives.
  • Uses use-stoichiometry for nonzero coefficient validation and term display.
  • Validates that complete reactions have at least one reactant and one product.
  • Omits coefficient 1 in conventional display formatting.
  • Keeps conditions as labels and descriptors only.
  • No automatic equation balancing.
  • No product inference.
  • No reaction mechanisms.
  • No kinetics, rate laws, or thermodynamics.
  • No equilibrium calculations.
  • No electrochemical potentials.
  • No hardcoded reaction database.
  • No runtime network access or external chemistry data.

§Relationship to use-chemistry

use-reaction is a focused child crate for chemical reaction representation primitives. The use-chemistry umbrella crate reexports it alongside stoichiometry, formula, compound, molecule, ion, oxidation-state, bond, element, isotope, periodic-table, atomic-number, atomic-mass, and electron-shell helpers. Chemical reaction representation primitives.

Structs§

Catalyst
A lightweight catalyst descriptor.
ChemicalReaction
A chemical reaction with an equation, optional conditions, and classification labels.
Product
A product-side reaction term.
Reactant
A reactant-side reaction term.
ReactionConditionSet
An ordered collection of reaction conditions.
ReactionEquation
A chemical reaction equation with reactants, products, and an arrow.
ReactionTerm
A formula-backed reaction term with a stoichiometric coefficient.
Solvent
A lightweight solvent descriptor.

Enums§

ReactionArrow
A reaction arrow style.
ReactionCondition
A lightweight reaction condition label.
ReactionDirection
A lightweight reaction direction label.
ReactionKind
A lightweight reaction classification label.
ReactionValidationError
Errors returned when constructing or validating reaction values.