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