Trait mzdata::io::MZFileReader

source ·
pub trait MZFileReader<C: CentroidLike + Default = CentroidPeak, D: DeconvolutedCentroidLike + Default = DeconvolutedPeak, S: SpectrumLike<C, D> = MultiLayerSpectrum<C, D>>: SpectrumSource<C, D, S> + Sized {
    // Required methods
    fn construct_index_from_stream(&mut self) -> u64;
    fn open_file(source: File) -> Result<Self>;

    // Provided methods
    fn read_index(&mut self, reader: Box<dyn Read>) -> Result<&Self, Error> { ... }
    fn write_index(&self, writer: Box<dyn Write>) -> Result<&Self, Error> { ... }
    fn open_path<P>(path: P) -> Result<Self>
       where P: Into<PathBuf> + Clone { ... }
}
Expand description

A trait defining some helper methods to make efficient use of indices automatic when opening a file from a path-like object.

Required Methods§

source

fn construct_index_from_stream(&mut self) -> u64

An on-trait method of constructing an index. Assumed to be a trivial wrapper.

source

fn open_file(source: File) -> Result<Self>

Given a regular file, construct a new instance without indexing.

Provided Methods§

source

fn read_index(&mut self, reader: Box<dyn Read>) -> Result<&Self, Error>

Re-construct an offset index from this readable object, assuming it is a JSON stream over the serialized index.

source

fn write_index(&self, writer: Box<dyn Write>) -> Result<&Self, Error>

source

fn open_path<P>(path: P) -> Result<Self>
where P: Into<PathBuf> + Clone,

The preferred method of opening a file from a path-like object. This method will open the file at the provided path, test whether there is an accompanied index file next to it on the file system, and if not, build one and save it or otherwise read in the index.

The index building process is usually neglible on “regular” IO file systems.

Object Safety§

This trait is not object safe.

Implementors§