chematic_core/lib.rs
1#![forbid(unsafe_code)]
2//! `chematic-core` — core cheminformatics types for the chematic ecosystem.
3//!
4//! Provides:
5//! - [`Element`]: periodic-table element indexed by atomic number.
6//! - [`Atom`]: a single atom with element, charge, isotope, aromaticity, chirality.
7//! - [`BondOrder`] / [`BondEntry`]: bond types and graph edges.
8//! - [`Molecule`] / [`MoleculeBuilder`]: undirected molecular graph (no external graph lib).
9//! - [`implicit_hcount`]: valence-based implicit hydrogen count for organic-subset atoms.
10//! - [`kekulize`] / [`apply_kekule`]: assign alternating single/double bonds to aromatic systems.
11//!
12//! # Design principles
13//! - Pure Rust, no C/C++ FFI, no unsafe.
14//! - Zero external dependencies: compiles to wasm32-unknown-unknown without modification.
15//! - Domain-aware abstractions: graph types carry chemical semantics, not just topology.
16
17pub mod atom;
18pub mod bond;
19pub mod coords3d;
20pub mod element;
21pub mod kekulization;
22pub mod molecule;
23pub mod stereo_geometry;
24pub mod stereo_group;
25pub mod valence;
26
27// Re-export the most commonly used types at crate root.
28pub use atom::{Atom, Chirality, CipCode, SquarePlanarPermutation};
29pub use bond::{BondEntry, BondOrder};
30pub use coords3d::{Coords3D, Point3};
31pub use element::Element;
32pub use kekulization::{KekuleError, KekuleResult, apply_kekule, kekulize};
33pub use molecule::{AtomIdx, BondIdx, MolError, Molecule, MoleculeBuilder, STEREO_H_SENTINEL};
34// `StereoConfiguration`/`CanonicalStereoConfiguration`/`canonicalize_configuration`/
35// `equivalent_under_rotation` are deliberately `pub(crate)`, not re-exported
36// here: all four are hardcoded to `[u32; 4]`, which only fits today's two
37// 4-coordinate geometries. Only the two arity-fixed-by-their-own-tag-semantics
38// bridge functions are public; see `stereo_geometry.rs`'s own doc comments
39// (on `StereoConfiguration` and each bridge function) for the full reasoning.
40pub use stereo_geometry::{
41 StereoGeometry, StereoGeometryError, remap_square_planar_tag, remap_tetrahedral_parity,
42};
43pub use stereo_group::{StereoGroup, StereoGroupKind};
44#[allow(deprecated)]
45pub use valence::total_hcount;
46pub use valence::{
47 ValenceError, bond_order_sum, implicit_hcount, valence_inferred_hcount, validate_valence,
48};