Skip to main content

readcon_core/
lib.rs

1pub mod array;
2mod columns;
3pub mod compression;
4pub mod conbin;
5pub mod correspondence;
6#[cfg(feature = "cuda")]
7pub mod cuda_array;
8pub mod distrib;
9#[cfg(feature = "mpi")]
10pub mod distrib_read;
11#[cfg(feature = "mpi")]
12pub mod distrib_write;
13pub mod error;
14pub mod extxyz_scan;
15mod fast_dec;
16pub mod ffi;
17pub mod frame_index;
18#[cfg(feature = "grammar")]
19pub mod grammar;
20pub mod helpers;
21pub mod hostlabel;
22/// Campaign screening scalars / CON ingest contracts for corpus stores (`readcon-db`).
23pub mod index_proj;
24pub mod iterators;
25pub mod parser;
26pub mod pdb_scan;
27/// RCSO/RCSB cooked numerics for a caller-side broadcast. No MPI in this crate.
28pub mod rcso;
29pub mod storage_dtype;
30pub mod stream;
31pub mod trajectory;
32pub mod types;
33pub mod units;
34pub mod writer;
35
36/// Foreign path / CON → CON write for stack migration (CLI + library).
37pub mod convert;
38
39#[cfg(feature = "metatensor")]
40pub mod metatensor_export;
41
42/// Chemfiles multi-format import (real impl behind `chemfiles` feature; stubs otherwise).
43pub mod chemfiles_import;
44
45/// Chemfiles selection grammar on CON frames (real impl behind `chemfiles` feature; stubs otherwise).
46pub mod chemfiles_selection;
47
48#[cfg(feature = "rpc")]
49pub mod rpc;
50
51// Re-export for generated capnp code which references crate::ReadCon_capnp
52#[cfg(feature = "rpc")]
53pub use rpc::read_con_capnp as ReadCon_capnp;
54
55#[cfg(feature = "python")]
56pub mod python;
57
58/// CON/convel format spec version implemented by this build.
59///
60/// - Version 1: column 5 present but semantics undefined. Readers MAY
61///   ignore it. No JSON metadata line.
62/// - Version 2: column 5 is the original atom index before type-based
63///   grouping; JSON line 2 with at least `{"con_spec_version": 2}`.
64/// - Version 3: same as v2 plus **required** `units` object on JSON **line 2**
65///   with non-empty `length` and `energy`. Writers emit canonical names
66///   (`angstrom`, `eV`). A velocities section on minor 1 also requires
67///   `units.time`. See `units::canonicalize_unit_expression`.
68///
69/// See `docs/orgmode/spec.org` for the full specification.
70pub const CON_SPEC_VERSION: u32 = 3;
71
72/// Minor implemented by this reader. Newer minors of major 3 are accepted.
73/// An unknown section is skipped only when the frame minor is greater than
74/// this value and `section_arity` gives the value-field count
75/// (CON-section.8, CON-section.12, D14).
76pub const CON_SPEC_MINOR: u32 = 1;
77
78/// Library version string, taken from the package version at compile time.
79/// `build.rs` checks that it matches the `VERSION` file.
80pub const VERSION: &str = env!("CARGO_PKG_VERSION");
81
82pub use correspondence::{
83    CorrespondenceError, IdentityCheck, atom_id_permutation, check_atom_id_consistency,
84    minimum_image_delta, minimum_image_displacements, reorder_like,
85};
86
87#[cfg(test)]
88mod tests {
89    use super::*;
90
91    #[test]
92    fn test_spec_version_is_current() {
93        assert_eq!(CON_SPEC_VERSION, 3);
94        assert_eq!(ffi::RKR_CON_SPEC_VERSION, CON_SPEC_VERSION);
95    }
96
97    #[test]
98    fn test_version_matches_source() {
99        let path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("VERSION");
100        let text = std::fs::read_to_string(&path).unwrap();
101        assert_eq!(text, format!("{VERSION}\n"));
102    }
103}