1mod clock;
2mod flag;
3mod formatting;
4mod key;
5mod measurement;
6mod observation;
7mod parsing;
8mod snr;
9
10use itertools::Itertools;
11use std::collections::BTreeMap;
12
13#[cfg(doc)]
14use crate::prelude::GroundStation;
15
16use crate::prelude::{Comments, Epoch, Matcher, Observable};
17
18#[cfg(feature = "serde")]
19use serde::{Deserialize, Serialize};
20
21pub use clock::ClockOffset;
22pub use flag::EpochFlag;
23pub use key::Key;
24pub use measurement::Measurements;
25pub use observation::Observation;
26pub use snr::SNR;
27
28#[derive(Clone, Debug, Default, PartialEq)]
30#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31pub struct Record {
32 pub comments: Comments,
34
35 pub measurements: BTreeMap<Key, Measurements>,
38}
39
40impl Record {
41 pub fn epochs_iter(&self) -> Box<dyn Iterator<Item = (Epoch, EpochFlag)> + '_> {
43 Box::new(self.measurements.keys().map(|k| (k.epoch, k.flag)).unique())
44 }
45
46 pub fn station_observables_iter<'a>(
48 &'a self,
49 matcher: &'a Matcher<'a>,
50 ) -> Box<dyn Iterator<Item = Observable> + '_> {
51 Box::new(
52 self.measurements
53 .iter()
54 .flat_map(move |(k, v)| {
55 v.observations.keys().filter_map(move |observable| {
56 if k.station.matches(&matcher) {
57 Some(*observable)
58 } else {
59 None
60 }
61 })
62 })
63 .unique(),
64 )
65 }
66}