1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use df_st_core::{DeserializeBestEffort, DeserializeBestEffortTypes, Filler, HasUnknown};
use df_st_derive::{DeserializeBestEffort, HasUnknown};
use indexmap::IndexMap;
use serde::{de, Serialize};
use serde_json::Value;
use std::collections::HashMap;

#[derive(Serialize, DeserializeBestEffort, Clone, Debug, HasUnknown, Default)]
pub struct HistoricalEra {
    pub name: Option<String>,
    pub start_year: Option<i32>,

    #[serde(flatten)]
    pub unknown: HashMap<String, Value>,
}

#[derive(Serialize, DeserializeBestEffort, Clone, Debug, HasUnknown, Default)]
pub struct HistoricalEras {
    pub historical_era: Option<Vec<HistoricalEra>>,

    #[serde(flatten)]
    pub unknown: HashMap<String, Value>,
}

impl Filler<df_st_core::HistoricalEra, HistoricalEra> for df_st_core::HistoricalEra {
    fn add_missing_data(&mut self, source: &HistoricalEra) {
        // self.id.add_missing_data(&source.id);
        self.name.add_missing_data(&source.name);
        self.start_year.add_missing_data(&source.start_year);
    }
}

impl PartialEq<df_st_core::HistoricalEra> for HistoricalEra {
    fn eq(&self, other: &df_st_core::HistoricalEra) -> bool {
        self.name == other.name
    }
}

impl std::hash::Hash for HistoricalEra {
    fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
        self.name.hash(state);
    }
}

impl Filler<Vec<df_st_core::HistoricalEra>, HistoricalEras> for Vec<df_st_core::HistoricalEra> {
    fn add_missing_data(&mut self, source: &HistoricalEras) {
        self.add_missing_data(&source.historical_era);
    }
}

impl Filler<IndexMap<u64, df_st_core::HistoricalEra>, HistoricalEras>
    for IndexMap<u64, df_st_core::HistoricalEra>
{
    fn add_missing_data(&mut self, source: &HistoricalEras) {
        self.add_missing_data(&source.historical_era);
    }
}