Skip to main content

readcon_core/
lib.rs

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