Expand description
§use-compound
Small chemical compound identity primitives for RustUse chemistry crates.
use-compound represents named chemical substances composed from formulas and
lightweight descriptors. It is intentionally structural: no compound database,
no naming engine, no reactions, no molecular geometry, no bonding model, and no
runtime data fetching.
§What this crate provides
| Item | Purpose |
|---|---|
Compound | Named compound with formula and descriptors |
CompoundName | Validated primary compound name |
CommonName | Optional validated common name |
SystematicName | Optional validated systematic name |
CompoundFormula | Compound-facing formula wrapper |
EmpiricalFormula | Empirical formula wrapper |
MolecularFormula | Molecular formula wrapper |
CompoundKind | Lightweight classification label |
CompoundIdentifier | Optional registry identifier |
CompoundRegistry | Registry namespace for identifiers |
CompoundValidationError | Structured construction and validation errors |
§Installation
[dependencies]
use-compound = "0.1.0"§Quick Examples
§Create a simple compound
use use_chemical_formula::ChemicalFormula;
use use_compound::{Compound, CompoundKind};
let water = Compound::new("water", ChemicalFormula::parse("H2O")?)?
.with_kind(CompoundKind::Molecular);
assert_eq!(water.name().as_str(), "water");
assert_eq!(water.formula().to_string(), "H2O");
assert_eq!(water.kinds(), &[CompoundKind::Molecular]);§Add names and identifiers
use use_chemical_formula::ChemicalFormula;
use use_compound::{Compound, CompoundIdentifier, CompoundKind};
let glucose = Compound::new("glucose", ChemicalFormula::parse("C6H12O6")?)?
.try_with_common_name("dextrose")?
.try_with_systematic_name("D-glucose")?
.with_kind(CompoundKind::Organic)
.try_with_identifier(CompoundIdentifier::pub_chem_cid("5793")?)?;
assert_eq!(glucose.common_name().map(|name| name.as_str()), Some("dextrose"));
assert_eq!(glucose.identifiers().len(), 1);§Scope
- Represents compound identity, names, formulas, kind labels, and identifiers.
- Uses
use-chemical-formulafor formula primitives. - Validates that names and identifier values are not empty.
- Keeps registry identifiers as lightweight wrappers only.
- No hardcoded compound database.
- No CAS checksum validation, PubChem lookup, InChI parsing, or SMILES parsing.
- No molecular geometry, bonding models, reactions, stoichiometry, molar mass, pH, solutions, thermochemistry, or simulation.
- No naming engine.
§Relationship to use-chemistry
use-compound is a focused child crate for compound identity primitives. The
use-chemistry umbrella crate reexports it alongside formula, element,
isotope, periodic-table, atomic-number, atomic-mass, and electron-shell helpers.
Chemical compound identity primitives.
Structs§
- Common
Name - A validated common compound name.
- Compound
- A named chemical compound with formula and lightweight descriptors.
- Compound
Formula - A compound-facing chemical formula wrapper.
- Compound
Identifier - A lightweight compound registry identifier.
- Compound
Name - A validated primary compound name.
- Empirical
Formula - An empirical formula wrapper.
- Molecular
Formula - A molecular formula wrapper.
- Systematic
Name - A validated systematic compound name.
Enums§
- Compound
Kind - A lightweight compound classification label.
- Compound
Registry - A compound identifier registry namespace.
- Compound
Validation Error - Errors returned when constructing compound values.