Trait mzdata::io::SpectrumSource
source · pub trait SpectrumSource<C: CentroidLike + Default = CentroidPeak, D: DeconvolutedCentroidLike + Default = DeconvolutedPeak, S: SpectrumLike<C, D> = MultiLayerSpectrum<C, D>>: Iterator<Item = S> {
Show 14 methods
// Required methods
fn reset(&mut self);
fn get_spectrum_by_id(&mut self, id: &str) -> Option<S>;
fn get_spectrum_by_index(&mut self, index: usize) -> Option<S>;
fn get_index(&self) -> &OffsetIndex;
fn set_index(&mut self, index: OffsetIndex);
// Provided methods
fn get_spectrum_by_time(&mut self, time: f64) -> Option<S> { ... }
fn len(&self) -> usize { ... }
fn is_empty(&self) -> bool { ... }
fn _offset_of_id(&self, id: &str) -> Option<u64> { ... }
fn _offset_of_index(&self, index: usize) -> Option<u64> { ... }
fn _offset_of_time(&mut self, time: f64) -> Option<u64> { ... }
fn iter(&mut self) -> SpectrumIterator<'_, C, D, S, Self> ⓘ
where Self: Sized { ... }
fn groups(
&mut self
) -> SpectrumGroupingIterator<SpectrumIterator<'_, C, D, S, Self>, C, D, S> ⓘ
where Self: Sized { ... }
fn into_groups(self) -> SpectrumGroupingIterator<Self, C, D, S> ⓘ
where Self: Sized { ... }
}
Expand description
A base trait defining the behaviors of a source of spectra.
Required Methods§
fn reset(&mut self)
sourcefn get_spectrum_by_id(&mut self, id: &str) -> Option<S>
fn get_spectrum_by_id(&mut self, id: &str) -> Option<S>
Retrieve a spectrum by it’s native ID
sourcefn get_spectrum_by_index(&mut self, index: usize) -> Option<S>
fn get_spectrum_by_index(&mut self, index: usize) -> Option<S>
Retrieve a spectrum by it’s integer index
sourcefn get_index(&self) -> &OffsetIndex
fn get_index(&self) -> &OffsetIndex
Access the spectrum offset index to enumerate all spectra by ID
sourcefn set_index(&mut self, index: OffsetIndex)
fn set_index(&mut self, index: OffsetIndex)
Set the spectrum offset index. This method shouldn’t be needed if not writing a new adapter
Provided Methods§
sourcefn get_spectrum_by_time(&mut self, time: f64) -> Option<S>
fn get_spectrum_by_time(&mut self, time: f64) -> Option<S>
Retrieve a spectrum by its scan start time Considerably more complex than seeking by ID or index, this involves a binary search over the spectrum index and assumes that spectra are stored in chronological order.
fn is_empty(&self) -> bool
sourcefn _offset_of_id(&self, id: &str) -> Option<u64>
fn _offset_of_id(&self, id: &str) -> Option<u64>
Helper method to support seeking to an ID
sourcefn _offset_of_index(&self, index: usize) -> Option<u64>
fn _offset_of_index(&self, index: usize) -> Option<u64>
Helper method to support seeking to an index
sourcefn _offset_of_time(&mut self, time: f64) -> Option<u64>
fn _offset_of_time(&mut self, time: f64) -> Option<u64>
Helper method to support seeking to a specific time. Considerably more complex than seeking by ID or index.
sourcefn iter(&mut self) -> SpectrumIterator<'_, C, D, S, Self> ⓘwhere
Self: Sized,
fn iter(&mut self) -> SpectrumIterator<'_, C, D, S, Self> ⓘwhere
Self: Sized,
Open a new iterator over this stream.
sourcefn groups(
&mut self
) -> SpectrumGroupingIterator<SpectrumIterator<'_, C, D, S, Self>, C, D, S> ⓘwhere
Self: Sized,
fn groups(
&mut self
) -> SpectrumGroupingIterator<SpectrumIterator<'_, C, D, S, Self>, C, D, S> ⓘwhere
Self: Sized,
Create a new SpectrumIterator
over self
and use that state to drive a SpectrumGroupIterator
sourcefn into_groups(self) -> SpectrumGroupingIterator<Self, C, D, S> ⓘwhere
Self: Sized,
fn into_groups(self) -> SpectrumGroupingIterator<Self, C, D, S> ⓘwhere
Self: Sized,
Implementors§
impl<'lifespan, C: CentroidLike + Default, D: DeconvolutedCentroidLike + Default, S: SpectrumLike<C, D>, R: SpectrumSource<C, D, S>> SpectrumSource<C, D, S> for SpectrumIterator<'lifespan, C, D, S, R>
impl<C: CentroidPeakAdapting + BuildFromArrayMap, D: DeconvolutedPeakAdapting + BuildFromArrayMap> SpectrumSource<C, D> for MzMLbReaderType<C, D>
They can also be used to fetch specific spectra by ID, index, or start
time when the underlying file stream supports io::Seek
.
impl<C: CentroidLike + Default + From<CentroidPeak> + BuildFromArrayMap, D: DeconvolutedCentroidLike + Default + From<DeconvolutedPeak> + BuildFromArrayMap, R: Read + Seek> SpectrumSource<C, D> for MZReaderType<R, C, D>
impl<C: CentroidLike + Default + From<CentroidPeak>, D: DeconvolutedCentroidLike + Default> SpectrumSource<C, D> for ThermoRawReaderType<C, D>
impl<C: CentroidLike + Default, D: DeconvolutedCentroidLike + Default, S: SpectrumLike<C, D> + Clone> SpectrumSource<C, D, S> for MemorySpectrumSource<C, D, S>
impl<C: CentroidLike + Default, D: DeconvolutedCentroidLike + Default, S: SpectrumLike<C, D>, I: Iterator<Item = S>> SpectrumSource<C, D, S> for StreamingSpectrumIterator<C, D, S, I>
impl<R: SeekRead, C: CentroidPeakAdapting + BuildFromArrayMap, D: DeconvolutedPeakAdapting + BuildFromArrayMap> SpectrumSource<C, D> for MzMLReaderType<R, C, D>
They can also be used to fetch specific spectra by ID, index, or start
time when the underlying file stream supports io::Seek
.