mod iterators

module iterators

Functions

fn parse_frames_parallel(file_contents: &str) -> Vec<Result<types::ConFrame, error::ParseError>>

Parses frames in parallel using rayon, splitting on frame boundaries.

Phase 1: sequential scan to find byte offsets of each frame’s start. Phase 2: parallel parse of each frame slice using rayon.

Requires the parallel feature.

fn read_all_frames(path: &Path) -> Result<Vec<types::ConFrame>, Box<dyn std::error::Error>>

Reads all frames from a file.

For files smaller than 64 KiB, uses a simple read_to_string to avoid the fixed overhead of mmap (VMA creation, page fault, munmap). For larger trajectory files, uses memory-mapped I/O to let the OS page cache handle the data.

fn read_first_frame(path: &Path) -> Result<types::ConFrame, Box<dyn std::error::Error>>

Reads only the first frame from a file.

More efficient than read_all_frames for single-frame access because it stops parsing after the first frame rather than collecting all of them.

Structs and Unions

struct ConFrameIterator<'a>

An iterator that lazily parses simulation frames from a .con or .convel file’s contents.

This struct wraps an iterator over the lines of a string and, upon each iteration, attempts to parse a complete ConFrame. Velocity sections are detected automatically: if a blank line follows the coordinate blocks, the velocity data is parsed into the atoms.

The iterator yields items of type Result<ConFrame, ParseError>, allowing for robust error handling for each frame.

Implementations

impl<'a> ConFrameIterator<'a>

Functions

fn forward(&mut self) -> Option<Result<(), error::ParseError>>

Skips the next frame without fully parsing its atomic data.

This is more efficient than next() if you only need to advance the iterator. It reads the frame’s header to determine how many lines to skip, including any velocity section if present.

Returns

  • Some(Ok(())) on a successful skip.

  • Some(Err(ParseError::...)) if there’s an error parsing the header.

  • None if the iterator is already at the end.

fn new(file_contents: &'a str) -> Self

Creates a new ConFrameIterator from a string slice of the entire file.

Arguments

  • file_contents - A string slice containing the text of one or more .con frames.

Traits implemented

impl<'a> Iterator for ConFrameIterator<'a>