Crate vasp_poscar [] [src]

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
");

Reexports

pub extern crate failure;
pub use builder::Builder;
pub use builder::Zeroed;

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.

ScaleLine

Represents the second line in a POSCAR file.

ValidationError

Covers all the reasons why RawPoscar::validate might get mad at you.

Traits

To3

Types convertible into [X; 3].

ToN3

Types convertable into Vec<[X; 3]>.