COSMolKit Rust
cosmolkit is the Rust facade crate for COSMolKit. It re-exports the molecular
model, chemistry operations, file I/O, fingerprints, drawing, batch helpers, and
protein structure APIs from cosmolkit-core.
Documentation
- Rust API documentation: https://docs.rs/cosmolkit/latest/cosmolkit/
- Core source layout:
../cosmolkit-core/src/README.md - Python package notes:
../../README.md - Development policy and operation rules:
../../dev/README.md
Installation
Quick Start
use ;
Molecule Operations
Normal Molecule operations return new values and leave the receiver
unchanged:
let mol = from_smiles?;
let with_h = mol.with_hydrogens?;
assert_ne!;
In-place operations are explicit and always end with _:
let mut mol = from_smiles?;
mol.add_hydrogens_?;
mol.sanitize_?;
The trailing underscore is reserved for in-place mutation on public Molecule
methods; it has no other meaning. In-place operations prioritize avoiding the
operation-system working-copy clone when molecule blocks are uniquely owned. If
an in-place operation returns an error, the receiver is not guaranteed to equal
its pre-call value; use the non-mutating operation when failure-preserving value
semantics are required.
Protein Structures
use Protein;
Batch Workflows
use ;
Examples
Development
Core validation should use operation-contract checks:
Python binding development:
The facade crate should stay thin. Public Rust APIs should be exposed through
cosmolkit or clearly scoped public modules, while molecule mutation continues
to go through registered operations in the core.