pub struct Frame { /* private fields */ }Expand description
A raw frame parsed from an extxyz file.
This struct represents the data for a single frame of an extxyz file,
including the number of atoms, metadata, and per-atom arrays.
You can iterate over the per-atom arrays directly:
ⓘ
for (name, value) in frame.arrs() {
println!("{name}: {value:?}");
}Or convert the metadata info into a HashMap for easy lookup:
ⓘ
let info_map = frame.info();
if let Some(temperature) = info_map.get("temperature") {
println!("Temperature: {:?}", temperature);
}Implementations§
Source§impl Frame
impl Frame
pub fn new( natoms: u32, info: Vec<(String, Value)>, arrs: Vec<(String, Value)>, ) -> Frame
Sourcepub fn set_comment(&mut self, comment: &str)
pub fn set_comment(&mut self, comment: &str)
override comment, if not exist, create the comment in the info field
Sourcepub fn info(&self) -> HashMap<&str, &Value>
pub fn info(&self) -> HashMap<&str, &Value>
Returns the frame metadata (info) as a HashMap for easy lookup.
Keys are &str slices pointing to the original Strings inside
DictHandler, and values are references to Value.
§Example
ⓘ
let info_map = frame.info();
if let Some(temperature) = info_map.get("temperature") {
println!("Temperature: {:?}", temperature);
}Sourcepub fn info_orderd(&self) -> Vec<(&str, &Value)>
pub fn info_orderd(&self) -> Vec<(&str, &Value)>
Return info as Vec<(&str, &Value)> keep the original order
Sourcepub fn arrs_orderd(&self) -> Vec<(&str, &Value)>
pub fn arrs_orderd(&self) -> Vec<(&str, &Value)>
Return arrs as Vec<(&str, &Value)> keep the original order
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnsafeUnpin for Frame
impl UnwindSafe for Frame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more