1pub mod bonding;
8pub mod cell;
9pub mod data;
10pub mod describe;
11pub mod elements;
12pub mod groups;
13pub mod lattice;
14pub mod limits;
15pub mod measure;
16pub mod neighbors;
17pub mod p1;
18pub mod param_presets;
19pub mod params;
20pub mod rings;
21pub mod scalars;
22pub mod selection;
23pub mod site;
24pub mod slab;
25mod spatial;
26pub mod structure;
27pub mod supercell;
28pub mod symop;
29pub mod transforms;
30
31pub use bonding::{Bond, BondGraph, BondRules, ExplicitBond, TopologyBond, perceive_bonds};
32pub use cell::cell_volume;
33pub use describe::describe_atom;
34pub use elements::{Element, Isotope, element_info};
35pub use groups::{GroupKind, GroupMatch, find_groups, group_counts};
36pub use lattice::{Lattice, lattice_info, lattice_minimum_image};
37pub use limits::{Limits, Profile, Verdict, limits_bounds, limits_check};
38pub use measure::{angle, centroid, distance, interplanar_angle, torsion};
39pub use neighbors::{Neighbor, neighbors, neighbors_of};
40pub use p1::{P1Atom, P1Cell};
41pub use param_presets::{PRESET_NAMES, preset, presets};
42pub use params::{ParamSet, ParamSpec, ParamType};
43pub use rings::{Ring, is_aromatic, ring_counts, ring_membership, rings};
44pub use scalars::{atom_charges, atom_masses, bond_lengths, coordination_numbers};
45pub use selection::{AtomId, Selection, TrackingTable};
46pub use site::Site;
47pub use slab::{Slab, make_slab, plane_angle, surface_basis};
48pub use structure::{
49 SCHEMA_VERSION, Structure, StructureBuilder, StructureDocument, StructureSummary,
50 structure_info,
51};
52pub use symop::SymOp;
53pub use transforms::{Ellipsoid, Plane, displacement_ellipsoid};
54
55#[must_use]
60pub fn version() -> &'static str {
61 env!("CARGO_PKG_VERSION")
62}
63
64#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
66pub enum Error {
67 #[error("invalid input: {0}")]
69 InvalidInput(String),
70 #[error("bundle {name}: compressed data is invalid: {reason}")]
72 DataCompression {
73 name: String,
75 reason: String,
77 },
78 #[error("bundle {name}: SHA-256 checksum mismatch")]
80 DataChecksum {
81 name: String,
83 },
84 #[error("bundle {name}: invalid SHA-256 digest")]
86 DataDigest {
87 name: String,
89 },
90 #[error("bundle {name}: JSON decoding failed: {reason}")]
92 DataJson {
93 name: String,
95 reason: String,
97 },
98 #[error("{0}")]
100 LimitExceeded(crate::limits::Verdict),
101 #[error("symmetry: {0}")]
103 Symmetry(String),
104}
105
106impl Error {
107 #[must_use]
111 pub fn code(&self) -> &'static str {
112 match self {
113 Self::InvalidInput(_) => "invalid_input",
114 Self::DataCompression { .. } => "data_compression",
115 Self::DataChecksum { .. } => "data_checksum",
116 Self::DataDigest { .. } => "data_digest",
117 Self::DataJson { .. } => "data_json",
118 Self::LimitExceeded(_) => "limit_exceeded",
119 Self::Symmetry(_) => "symmetry",
120 }
121 }
122
123 #[must_use]
125 pub fn message(&self) -> String {
126 self.to_string()
127 }
128}