rustyms/spectrum/
peaks.rs

1//! General trait for a spectrum
2
3use std::iter::FusedIterator;
4
5use crate::system::f64::MassOverCharge;
6
7/// The trait for all spectra that contain peaks.
8pub trait PeakSpectrum:
9    Extend<Self::PeakType>
10    + IntoIterator<Item = Self::PeakType>
11    + std::ops::Index<usize, Output = Self::PeakType>
12{
13    /// The type of peaks this spectrum contains
14    type PeakType;
15    /// The type of spectrum iterator this spectrum generates
16    type Iter<'a>: DoubleEndedIterator + ExactSizeIterator + FusedIterator
17    where
18        Self: 'a;
19    /// Return the slice of peaks that is within the given tolerance bounds.
20    fn binary_search(&self, low: MassOverCharge, high: MassOverCharge) -> &[Self::PeakType];
21    /// Get the full spectrum
22    fn spectrum(&self) -> Self::Iter<'_>;
23    /// Add a single peak
24    fn add_peak(&mut self, item: Self::PeakType);
25}