Struct molly::XTCReader

source ·
pub struct XTCReader<R> {
    pub file: R,
    pub step: usize,
}

Fields§

§file: R§step: usize

Implementations§

source§

impl XTCReader<File>

source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>

source§

impl<R: Read> XTCReader<R>

source

pub fn new(reader: R) -> Self

source

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.

source

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.

source

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.

source

pub fn read_frame(&mut self, frame: &mut Frame) -> Result<()>

Reads and returns a Frame and advances one step.

source

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.

source

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>

source

pub fn home(&mut self) -> Result<()>

Reset the reader to its initial position.

Go back to the first frame.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

Trait Implementations§

source§

impl<R: Clone> Clone for XTCReader<R>

source§

fn clone(&self) -> XTCReader<R>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<R: Debug> Debug for XTCReader<R>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for XTCReader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for XTCReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for XTCReader<R>
where R: Send,

§

impl<R> Sync for XTCReader<R>
where R: Sync,

§

impl<R> Unpin for XTCReader<R>
where R: Unpin,

§

impl<R> UnwindSafe for XTCReader<R>
where R: UnwindSafe,

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.