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
parallelfeature.
- 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_stringto 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_framesfor 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
.conor.convelfile’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.Noneif the iterator is already at the end.
- fn new(file_contents: &'a str) -> Self¶
Creates a new
ConFrameIteratorfrom a string slice of the entire file.Arguments
file_contents- A string slice containing the text of one or more.conframes.
Traits implemented
- impl<'a> Iterator for ConFrameIterator<'a>¶