castep_cell_io/parsing/
mod.rs

1mod cell_parser;
2mod error;
3pub mod helpers;
4
5pub use error::CellParseError;
6
7use crate::cell_document::{CellEntries, IonicPositionBlock, LatticeParamBlock};
8
9#[derive(Debug)]
10pub struct CellParser<'a> {
11    input: &'a str,
12    lattice_param: Option<LatticeParamBlock>,
13    ionic_positions: Option<IonicPositionBlock>,
14    other_entries: Vec<CellEntries>,
15}
16
17#[cfg(test)]
18mod test {
19    use std::{fs, path::Path};
20
21    use super::CellParser;
22
23    #[test]
24    fn test_cell_parser() {
25        let root = env!("CARGO_MANIFEST_DIR");
26        let path = Path::new(root).join("FePcCOOH_N1_copy.cell");
27        let input = fs::read_to_string(path).unwrap();
28        let mut cell_parser = CellParser::from(&input);
29        let cell_doc = cell_parser.parse();
30        println!("Parse status: {:?}", cell_doc.is_ok());
31        dbg!(cell_doc.unwrap());
32        // let path = Path::new(root).join("SAC_GDY_V_test.cell");
33        // let input = fs::read_to_string(path).unwrap();
34        // let mut cell_parser = CellParser::from(&input);
35        // let cell_doc = cell_parser.parse();
36        // println!("Parse status: {:?}", cell_doc.is_ok());
37        // println!("{}", cell_doc.unwrap());
38    }
39}