doris_rs/
matcher.rs

1//! DORIS ground station dataset matcher
2use crate::prelude::DOMES;
3
4#[cfg(doc)]
5use crate::prelude::{GroundStation, Record, DORIS};
6
7/// [Matcher] is used to easily identify [GroundStation]s from a [DORIS] [Record].
8#[derive(Debug, Clone, PartialEq)]
9pub enum Matcher<'a> {
10    /// Search by station ID#
11    /// ```
12    /// use std::str::FromStr;
13    /// use doris_rs::prelude::*;
14    ///
15    /// let doris = DORIS::from_gzip_file("data/DOR/V3/cs2rx18164.gz")
16    ///     .unwrap();
17    ///
18    /// // Because Station IDs are arbitrary and file dependent,
19    /// // it should be very rare to use this search method.
20    /// let station_13 = Matcher::ID(13);
21    ///
22    /// let toulouse = GroundStation::default()
23    ///     .with_domes(DOMES::from_str("10003S005").unwrap())
24    ///     .with_site_name("TOULOUSE") // site name
25    ///     .with_site_label("TLSB")    // site label/mnemonic
26    ///     .with_unique_id(13)         // file dependent
27    ///     .with_frequency_shift(0)    // f1/f2 site shift for this day
28    ///     .with_beacon_revision(3);   // DORIS 3rd generation
29    ///
30    /// // Stations helper (example)
31    /// assert_eq!(doris.ground_station(station_13), Some(toulouse));
32    /// ```
33    ID(u16),
34
35    /// Search by site name
36    /// ```
37    /// use std::str::FromStr;
38    /// use doris_rs::prelude::*;
39    ///
40    /// let doris = DORIS::from_gzip_file("data/DOR/V3/cs2rx18164.gz")
41    ///     .unwrap();
42    ///
43    /// // Match by site name (full name), case insensitive.
44    /// let to_match = Matcher::Site("toulouse");
45    ///
46    /// let toulouse = GroundStation::default()
47    ///     .with_domes(DOMES::from_str("10003S005").unwrap())
48    ///     .with_site_name("TOULOUSE") // site name
49    ///     .with_site_label("TLSB")    // site label/mnemonic
50    ///     .with_unique_id(13)         // file dependent
51    ///     .with_frequency_shift(0)    // f1/f2 site shift for this day
52    ///     .with_beacon_revision(3);   // DORIS 3rd generation
53    ///
54    /// // Stations helper (example)
55    /// assert_eq!(doris.ground_station(to_match), Some(toulouse));
56    /// ```
57    Site(&'a str),
58
59    /// Search by station (mnemonic) label
60    /// ```
61    /// use std::str::FromStr;
62    /// use doris_rs::prelude::*;
63    ///
64    /// let doris = DORIS::from_gzip_file("data/DOR/V3/cs2rx18164.gz")
65    ///     .unwrap();
66    ///
67    /// // Match by site name (full name), case insensitive.
68    /// let to_match = Matcher::Label("tlsb");
69    ///
70    /// let toulouse = GroundStation::default()
71    ///     .with_domes(DOMES::from_str("10003S005").unwrap())
72    ///     .with_site_name("TOULOUSE") // site name
73    ///     .with_site_label("TLSB")    // site label/mnemonic
74    ///     .with_unique_id(13)         // file dependent
75    ///     .with_frequency_shift(0)    // f1/f2 site shift for this day
76    ///     .with_beacon_revision(3);   // DORIS 3rd generation
77    ///
78    /// // Stations helper (example)
79    /// assert_eq!(doris.ground_station(to_match), Some(toulouse));
80    /// ```
81    Label(&'a str),
82
83    /// Search by DOMES code
84    /// ```
85    /// use std::str::FromStr;
86    /// use doris_rs::prelude::*;
87    ///
88    /// let doris = DORIS::from_gzip_file("data/DOR/V3/cs2rx18164.gz")
89    ///     .unwrap();
90    ///
91    /// // Match by site name (full name), case insensitive.
92    /// let domes = DOMES::from_str("10003S005")
93    ///     .unwrap();
94    ///
95    /// assert_eq!(domes.area, 100);
96    /// assert_eq!(domes.site, 3);
97    /// assert_eq!(domes.sequential, 5);
98    /// assert_eq!(domes.point, DOMESTrackingPoint::Instrument);
99    ///
100    /// let to_match = Matcher::DOMES(domes);
101    ///
102    /// let toulouse = GroundStation::default()
103    ///     .with_domes(DOMES::from_str("10003S005").unwrap())
104    ///     .with_site_name("TOULOUSE") // site name
105    ///     .with_site_label("TLSB")    // site label/mnemonic
106    ///     .with_unique_id(13)         // file dependent
107    ///     .with_frequency_shift(0)    // f1/f2 site shift for this day
108    ///     .with_beacon_revision(3);   // DORIS 3rd generation
109    ///
110    /// // Stations helper (example)
111    /// assert_eq!(doris.ground_station(to_match), Some(toulouse));
112    /// ```
113    DOMES(DOMES),
114}