MassSpectrometryReadWriteProcess

Trait MassSpectrometryReadWriteProcess 

Source
pub trait MassSpectrometryReadWriteProcess<C = CentroidPeak, D = DeconvolutedPeak>{
    type ErrorType: From<Error>;

    // Required method
    fn task<R, W>(&self, reader: R, writer: W) -> Result<(), Self::ErrorType>
       where R: RandomAccessSpectrumIterator<C, D> + MSDataFileMetadata + SpectrumSource<C, D> + Send + Any + 'static,
             W: SpectrumWriter<C, D> + Send + Any + 'static;

    // Provided methods
    fn main<P, Q>(
        &self,
        read_path: P,
        write_path: Q,
    ) -> Result<(), Self::ErrorType>
       where P: Into<Source<C, D>>,
             Q: Into<Sink<C, D>> { ... }
    fn open_reader<P, Q>(
        &self,
        read_path: P,
        write_path: Q,
    ) -> Result<(), Self::ErrorType>
       where P: Into<Source<C, D>>,
             Q: Into<Sink<C, D>> { ... }
    fn open_writer<Q, R>(
        &self,
        reader: R,
        reader_format: MassSpectrometryFormat,
        write_path: Q,
    ) -> Result<(), Self::ErrorType>
       where Q: Into<Sink<C, D>>,
             R: RandomAccessSpectrumIterator<C, D> + MSDataFileMetadata + SpectrumSource<C, D> + Send + Any + 'static { ... }
    fn transform_reader<R>(
        &self,
        reader: R,
        format: MassSpectrometryFormat,
    ) -> Result<R, Self::ErrorType>
       where R: RandomAccessSpectrumIterator<C, D> + MSDataFileMetadata + SpectrumSource<C, D> + Send + Any + 'static { ... }
    fn transform_writer<R, W>(
        &self,
        reader: R,
        reader_format: MassSpectrometryFormat,
        writer: W,
        writer_format: MassSpectrometryFormat,
    ) -> Result<(R, W), Self::ErrorType>
       where R: RandomAccessSpectrumIterator<C, D> + MSDataFileMetadata + SpectrumSource<C, D> + Any + Send + 'static,
             W: SpectrumWriter<C, D> + MSDataFileMetadata + Send + 'static { ... }
}
Expand description

Encapsulate the read-transform-write process for mass spectrometry data sources.

This trait handles all the gory details of file format inference with open_reader and open_writer, leaving open the chance to customize those objects after their creation in transform_reader and transform_writer respectively.

The only function that must be implemented explicitly is task which receives the reader and writer, and must contain the logic to transmit one from the other with whatever transformations you wish to apply between them.

Required Associated Types§

Required Methods§

Source

fn task<R, W>(&self, reader: R, writer: W) -> Result<(), Self::ErrorType>
where R: RandomAccessSpectrumIterator<C, D> + MSDataFileMetadata + SpectrumSource<C, D> + Send + Any + 'static, W: SpectrumWriter<C, D> + Send + Any + 'static,

The place where the work happens to transmit data from reader to writer with whatever transformations need to take place.

Provided Methods§

Source

fn main<P, Q>(&self, read_path: P, write_path: Q) -> Result<(), Self::ErrorType>
where P: Into<Source<C, D>>, Q: Into<Sink<C, D>>,

The main entry point that starts the whole system running on a reader Source and a writer Sink, or equivalent objects.

By default this just invokes MassSpectrometryReadWriteProcess::open_reader, but if any additional configuration needs to be done before that happens, it can be done here. Examples include creating a thread pool, temporary files or directories, or some other scoped activity.

Source

fn open_reader<P, Q>( &self, read_path: P, write_path: Q, ) -> Result<(), Self::ErrorType>
where P: Into<Source<C, D>>, Q: Into<Sink<C, D>>,

Opens the reader, transforms it with MassSpectrometryReadWriteProcess::transform_reader, and then passes control to MassSpectrometryReadWriteProcess::open_writer

Source

fn open_writer<Q, R>( &self, reader: R, reader_format: MassSpectrometryFormat, write_path: Q, ) -> Result<(), Self::ErrorType>
where Q: Into<Sink<C, D>>, R: RandomAccessSpectrumIterator<C, D> + MSDataFileMetadata + SpectrumSource<C, D> + Send + Any + 'static,

Opens the writer, transforms it with MassSpectrometryReadWriteProcess::transform_writer, and then passes control to MassSpectrometryReadWriteProcess::task

Source

fn transform_reader<R>( &self, reader: R, format: MassSpectrometryFormat, ) -> Result<R, Self::ErrorType>

Customize the reader in some way. The format is passed along to allow each format to be customized explicitly.

A no-op by default.

Source

fn transform_writer<R, W>( &self, reader: R, reader_format: MassSpectrometryFormat, writer: W, writer_format: MassSpectrometryFormat, ) -> Result<(R, W), Self::ErrorType>
where R: RandomAccessSpectrumIterator<C, D> + MSDataFileMetadata + SpectrumSource<C, D> + Any + Send + 'static, W: SpectrumWriter<C, D> + MSDataFileMetadata + Send + 'static,

Customize the writer in some way. The format is passed along to allow each format to be customized explicitly, and the reader is provided side-by-side to permit additional information to be used.

A no-op by default.

§Note

The caller already invokes MSDataFileMetadata::copy_metadata_from

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§