inchi 0.1.0

Safe, idiomatic Rust bindings to the IUPAC InChI library for generating InChI and InChIKey identifiers
Documentation
  • Coverage
  • 100%
    137 out of 137 items documented20 out of 21 items with examples
  • Size
  • Source code size: 156.26 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.46 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 22s Average build duration of successful builds.
  • all releases: 21s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Vitruves/inchi-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Vitruves
inchi-0.1.0 has been yanked.

inchi

crates.io docs.rs

Safe, idiomatic Rust bindings to the IUPAC InChI reference library, for generating and parsing InChI and InChIKey chemical identifiers. The C library is vendored and statically linked via inchi-sys — no system install, no network at build time. No unsafe is exposed; native allocations are freed automatically.

Install

[dependencies]
inchi = "0.1"

Example

From a Molfile/SDF record (pass () for default options):

use inchi::{from_molfile, inchikey};

let out = from_molfile(molfile, ())?;
let inchi = out.inchi();        // "InChI=1S/H2O/h1H2"
let key = inchikey(inchi)?;     // "XLYOFNOQVPJJNP-UHFFFAOYSA-N"

Or build a structure programmatically:

use inchi::{Molecule, Atom, BondOrder};

let mut mol = Molecule::new();
let c = mol.add_atom(Atom::new("C"));
let o = mol.add_atom(Atom::new("O"));
mol.add_bond(c, o, BondOrder::Double)?;
let inchi = mol.to_inchi(())?.into_inchi();

Customize generation by passing Options instead of ():

use inchi::{from_molfile, Options, StereoMode};

let out = from_molfile(molfile, Options::new().fixed_h(true).stereo(StereoMode::Relative))?;

API

Direction Entry points
Structure → InChI from_molfile, Molecule::to_inchi
InChI → structure struct_from_inchi, struct_from_inchi_ex (polymers), struct_from_aux_info
InChI → InChIKey inchikey, inchikey_with_hashes
Convert / validate inchi_to_inchi, check_inchi, check_inchikey

Generation is configured with Options (stereo, fixed-H, metals, tautomers, timeout, polymers, …). Polymers (CTFile SRU Sgroups) are supported via Options::polymers and Molecule::add_polymer_unit.

Full reference, semantics, and runnable examples: https://docs.rs/inchi.

Features

Feature Default Description
key yes InChIKey computation (GetINCHIKeyFromINCHI).
regenerate-bindings no Regenerate FFI bindings with bindgen (needs libclang).

Notes

  • The InChI C library keeps static state and is not re-entrant; all calls are serialized behind a global lock. The public types are Send + Sync.
  • MSRV: Rust 1.74. Raising it is a semver-breaking change.

License

MIT. Bundles the IUPAC InChI software (MIT); see inchi-sys.