Expand description
Library for reading and writing VASP POSCAR files.
See the Poscar
type for more details.
use vasp_poscar::{Poscar, ScaleLine};
const EXAMPLE: &'static str = "\
cubic diamond
3.7
0.5 0.5 0.0
0.0 0.5 0.5
0.5 0.0 0.5
C
2
Direct
0.0 0.0 0.0
0.25 0.25 0.25
";
// read from a BufRead instance, such as &[u8] or BufReader<File>
let poscar = Poscar::from_reader(EXAMPLE.as_bytes())?;
// get a RawPoscar object with public fields you can freely match on and manipulate
let mut poscar = poscar.into_raw();
assert_eq!(poscar.scale, ScaleLine::Factor(3.7));
poscar.comment = "[Subject Name Here] was here".into();
poscar.scale = ScaleLine::Volume(10.0);
// Turn the RawPoscar back into a Poscar
let poscar = poscar.validate()?;
// Poscar implements Display
assert_eq!(
format!("{}", poscar),
"\
[Subject Name Here] was here
-10.0
0.5 0.5 0.0
0.0 0.5 0.5
0.5 0.0 0.5
C
2
Direct
0.0 0.0 0.0
0.25 0.25 0.25
");
Re-exports§
Modules§
- builder
- Poscar construction through the builder pattern.
Structs§
- Poscar
- Represents a POSCAR file.
- RawPoscar
- Unencumbered
struct
form of a Poscar with public data members.
Enums§
- Coords
- Represents data that can either be in direct units or cartesian.
- Scale
Line - Represents the second line in a POSCAR file.
- Validation
Error - Covers all the reasons why
RawPoscar::validate
might get mad at you.