molio 0.2.0

A library for reading chemical file formats
Documentation
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2025 William Bro-Jørgensen
//
// See LICENSE at the project root for full text.

#![doc = include_str!("../README.md")]
pub mod angle;
pub mod atom;
pub mod bond;
pub mod connectivity;
pub mod dihedral;
pub mod error;
pub mod extendedxyzparser;
pub mod format;
pub mod formats;
pub mod frame;
pub mod improper;
pub mod property;
pub mod residue;
pub mod topology;
pub mod trajectory;
pub mod unit_cell;

use std::path::Path;

use crate::trajectory::Trajectory;

/// Read a trajectory file and return the total number of atoms processed
#[must_use]
pub fn read_trajectory(path: &Path) -> usize {
    let mut trajectory = Trajectory::open(path).unwrap();
    let mut total_atoms = 0;
    while let Some(next_frame) = trajectory.read().unwrap() {
        total_atoms += next_frame.size();
    }
    total_atoms
}