Skip to main content

ferric_fred/
updates_filter.rs

1/// Which series `series/updates` returns, by FRED's `filter_value` parameter.
2#[derive(Debug, Clone, Copy, PartialEq, Eq)]
3#[non_exhaustive]
4pub enum UpdatesFilter {
5    /// All updated series (`all`, FRED's default).
6    All,
7    /// Macroeconomic series only (`macro`).
8    Macro,
9    /// Regional series only (`regional`).
10    Regional,
11}
12
13impl UpdatesFilter {
14    /// The FRED query code for this filter.
15    pub fn query_code(self) -> &'static str {
16        match self {
17            Self::All => "all",
18            Self::Macro => "macro",
19            Self::Regional => "regional",
20        }
21    }
22}
23
24#[cfg(test)]
25mod tests {
26    use super::*;
27
28    #[test]
29    fn query_codes_match_fred() {
30        assert_eq!(UpdatesFilter::All.query_code(), "all");
31        assert_eq!(UpdatesFilter::Macro.query_code(), "macro");
32        assert_eq!(UpdatesFilter::Regional.query_code(), "regional");
33    }
34}