Skip to main content

readcon_core/
lib.rs

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