pub struct XTCReader<R> {
pub file: R,
pub step: usize,
}Fields§
§file: R§step: usizeImplementations§
source§impl<R: Read> XTCReader<R>
impl<R: Read> XTCReader<R>
pub fn new(reader: R) -> Self
sourcepub fn read_header(&mut self) -> Result<Header>
pub fn read_header(&mut self) -> Result<Header>
Read the header at the start of a frame.
Assumes the internal reader is at the start of a new frame header.
sourcepub fn read_smol_positions(
&mut self,
natoms: usize,
frame: &mut Frame,
atom_selection: &AtomSelection
) -> Result<usize>
pub fn read_smol_positions( &mut self, natoms: usize, frame: &mut Frame, atom_selection: &AtomSelection ) -> Result<usize>
Read a small number of uncompressed positions.
If successful, returns the number of compressed bytes that were read.
§Panics
natoms must be 9 or less, otherwise the positions must be decompressed and cannot be read
directly through this function.
Oh xtc, you are so fucking weird.
sourcepub fn read_all_frames(&mut self) -> Result<Box<[Frame]>>
pub fn read_all_frames(&mut self) -> Result<Box<[Frame]>>
A convenience function to read all frames in a trajectory.
It is likely more efficient to use XTCReader::read_frame if you are only interested in
the values of a single frame at a time.
sourcepub fn read_frame(&mut self, frame: &mut Frame) -> Result<()>
pub fn read_frame(&mut self, frame: &mut Frame) -> Result<()>
Reads and returns a Frame and advances one step.
sourcepub fn read_frame_with_selection(
&mut self,
frame: &mut Frame,
atom_selection: &AtomSelection
) -> Result<()>
pub fn read_frame_with_selection( &mut self, frame: &mut Frame, atom_selection: &AtomSelection ) -> Result<()>
Reads and returns a Frame according to the AtomSelection, and advances one step.
sourcepub fn read_frame_with_scratch(
&mut self,
frame: &mut Frame,
scratch: &mut Vec<u8>,
atom_selection: &AtomSelection
) -> Result<()>
pub fn read_frame_with_scratch( &mut self, frame: &mut Frame, scratch: &mut Vec<u8>, atom_selection: &AtomSelection ) -> Result<()>
Reads and returns a Frame and advances one step, internally reading the compressed data
into scratch.
§Note
This function performs the work of XTCReader::read_frame, but leaves all allocations to
the caller.
The contents of scratch should not be depended upon! It just serves as a scratch buffer
for the inner workings of decoding.
In most cases, XTCReader::read_frame is more than sufficient. This function only serves
to make specific optimization possible.
source§impl XTCReader<File>
impl XTCReader<File>
sourcepub fn home(&mut self) -> Result<()>
pub fn home(&mut self) -> Result<()>
Reset the reader to its initial position.
Go back to the first frame.
sourcepub fn determine_offsets_exclusive(
&mut self,
until: Option<usize>
) -> Result<Box<[u64]>>
pub fn determine_offsets_exclusive( &mut self, until: Option<usize> ) -> Result<Box<[u64]>>
Returns the offsets from the headers in this XTCReader<R> from its current position.
The last value points one byte after the last byte in the reader.
If this function is called when the internal reader is not at its starting position, the
frame offsets from its position are determined. If you wish to determine the offsets from
the initial reader position, call XTCReader::home before calling this function.
§Errors
This function will pass through any reader errors.
sourcepub fn determine_offsets(&mut self, until: Option<usize>) -> Result<Box<[u64]>>
pub fn determine_offsets(&mut self, until: Option<usize>) -> Result<Box<[u64]>>
Returns the offsets of this XTCReader<R> from its current position.
The last value points to the start of the last frame.
If this function is called when the internal reader is not at its starting position, the
frame offsets from its position are determined. If you wish to determine the offsets from
the initial reader position, call XTCReader::home before calling this function.
§Errors
This function will pass through any reader errors.
sourcepub fn determine_frame_sizes(
&mut self,
until: Option<usize>
) -> Result<Box<[u64]>>
pub fn determine_frame_sizes( &mut self, until: Option<usize> ) -> Result<Box<[u64]>>
Returns the frame sizes of this XTCReader<R>.
§Errors
This function will pass through any reader errors.
sourcepub fn read_frame_at_offset<const BUFFERED: bool>(
&mut self,
frame: &mut Frame,
offset: u64,
atom_selection: &AtomSelection
) -> Result<()>
pub fn read_frame_at_offset<const BUFFERED: bool>( &mut self, frame: &mut Frame, offset: u64, atom_selection: &AtomSelection ) -> Result<()>
Seeks to offset, then reads and returns a Frame and advances one step.
§Note
The BUFFERED const generic value can be used to set whether the frame reader will read in
a buffered manner or not at compile time.
Buffered reading is most favorable when a small number of positions are read from the top of the frame (leaving many positions that do not need to be read at the bottom), especially at the point where disk read speed is a bottleneck.
sourcepub fn read_frames<const BUFFERED: bool>(
&mut self,
frames: &mut impl Extend<Frame>,
frame_selection: &FrameSelection,
atom_selection: &AtomSelection
) -> Result<usize>
pub fn read_frames<const BUFFERED: bool>( &mut self, frames: &mut impl Extend<Frame>, frame_selection: &FrameSelection, atom_selection: &AtomSelection ) -> Result<usize>
Append Frames to the frames buffer according to a [Selection].
If successful, it will return the number of frames that were read. This can be useful since the selection itself is not enough to tell how many frames will actually be read.
§Note
The BUFFERED const generic value can be used to set whether the frame reader will read in
a buffered manner or not at compile time.
Buffered reading is most favorable when a small number of positions are read from the top of the frame (leaving many positions that do not need to be read at the bottom), especially at the point where disk read speed is a bottleneck.
sourcepub fn read_frame_with_selection_buffered(
&mut self,
frame: &mut Frame,
atom_selection: &AtomSelection
) -> Result<()>
pub fn read_frame_with_selection_buffered( &mut self, frame: &mut Frame, atom_selection: &AtomSelection ) -> Result<()>
Reads and returns a Frame according to the AtomSelection, and advances one step.
sourcepub fn read_frame_with_scratch_buffered(
&mut self,
frame: &mut Frame,
scratch: &mut Vec<u8>,
atom_selection: &AtomSelection
) -> Result<()>
pub fn read_frame_with_scratch_buffered( &mut self, frame: &mut Frame, scratch: &mut Vec<u8>, atom_selection: &AtomSelection ) -> Result<()>
Reads and returns a Frame and advances one step, internally reading the compressed data
into scratch.
§Note
This function performs the work of XTCReader::read_frame, but leaves all allocations to
the caller.
The contents of scratch should not be depended upon! It just serves as a scratch buffer
for the inner workings of decoding.
In most cases, XTCReader::read_frame is more than sufficient. This function only serves
to make specific optimization possible.