Skip to main content

Frame

Struct Frame 

Source
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

Source

pub fn new( natoms: u32, info: Vec<(String, Value)>, arrs: Vec<(String, Value)>, ) -> Frame

Source

pub fn natoms(&self) -> u32

Returns the number of atoms in the frame.

Source

pub fn set_comment(&mut self, comment: &str)

override comment, if not exist, create the comment in the info field

Source

pub fn arrs(&self) -> HashMap<&str, &Value>

Returns the frame metadata (arrs) 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 arrs_map = frame.arrs();
if let Some(pos) = arrs_map.get("pos") {
    println!("Positions: {:?}", pos);
}
Source

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);
}
Source

pub fn info_orderd(&self) -> Vec<(&str, &Value)>

Return info as Vec<(&str, &Value)> keep the original order

Source

pub fn arrs_orderd(&self) -> Vec<(&str, &Value)>

Return arrs as Vec<(&str, &Value)> keep the original order

Trait Implementations§

Source§

impl Debug for Frame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.