Skip to main content

phasesmith_io/
lib.rs

1//! Bounded native input adapters for application hosts.
2//!
3//! This crate parses external text into validated `phasesmith-model` and
4//! crystallographic records. It owns syntax, provenance, diagnostics, format
5//! detection, and pre-allocation limits; it does not own refinement or GUI
6//! state. Applications normally use it through
7//! [`phasesmith::io`](https://docs.rs/phasesmith/latest/phasesmith/).
8//!
9//! # Powder data
10//!
11//! ```
12//! use phasesmith_io::{PowderFormat, PowderReadLimits, parse_powder_text};
13//!
14//! let data = parse_powder_text(
15//!     "20.0 100.0 2.0\n20.1 120.0 2.5\n",
16//!     PowderFormat::Columns,
17//!     1,
18//!     PowderReadLimits::default(),
19//! )?;
20//! assert_eq!(data.pattern.sample_count(), 2);
21//! # Ok::<(), Box<dyn std::error::Error>>(())
22//! ```
23//!
24//! [`read_powder_file`] and [`parse_powder_text`] support plain columns and
25//! selected GSAS formats. [`read_cif_file`] and [`parse_cif_text`] implement the
26//! native CIF path with structured diagnostics. Space-group lookup functions
27//! expose database provenance and do not require a CIF parser.
28//!
29//! Keep default limits for ordinary trusted files; tighten them when accepting
30//! untrusted uploads. Limit errors are distinct from syntax and domain errors.
31
32mod cif;
33mod powder;
34mod space_groups;
35mod tof_instrument;
36
37pub use cif::{
38    CifAnisotropicDisplacement, CifAtomSite, CifDiagnostic, CifDiagnosticSeverity, CifIoError,
39    CifReadLimits, CifReadResult, CifStructure, CifStructureSource, DisplacementConvention,
40    NATIVE_CIF_BACKEND, NATIVE_CIF_BACKEND_VERSION, parse_cif_text, read_cif_file,
41};
42
43pub use powder::{
44    PowderData, PowderFormat, PowderIoError, PowderReadLimits, TofPowderData, TofPowderFormat,
45    parse_powder_text, parse_tof_powder_text, parse_tof_powder_text_as, read_powder_file,
46    read_tof_powder_file, read_tof_powder_file_as,
47};
48pub use space_groups::{
49    SPACE_GROUP_DATABASE_PROVENANCE, SpaceGroupDatabaseProvenance, SpaceGroupInfo,
50    SpaceGroupLookupError, space_group_by_hall_symbol, space_group_by_number,
51    space_group_by_symbol,
52};
53pub use tof_instrument::{
54    GsasTofInstrumentData, GsasTofInstrumentIoError, GsasTofInstrumentReadLimits,
55    parse_gsas_tof_instrument_text, read_gsas_tof_instrument_file,
56};