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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
use df_st_core::{Filler, HasUnknown};
use df_st_derive::HasUnknown;
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
#[derive(Serialize, Deserialize, Clone, Debug, HasUnknown)]
pub struct HERelationship {
pub event: i32,
pub year: Option<i32>,
pub seconds72: Option<i32>,
pub relationship: Option<String>,
pub source_hf: Option<i32>,
pub target_hf: Option<i32>,
#[serde(flatten)]
pub unknown: HashMap<String, Value>,
}
#[derive(Serialize, Deserialize, Clone, Debug, HasUnknown)]
pub struct HERelationships {
pub historical_event_relationship: Option<Vec<HERelationship>>,
#[serde(flatten)]
pub unknown: HashMap<String, Value>,
}
impl Filler<df_st_core::HistoricalEvent, HERelationship> for df_st_core::HistoricalEvent {
fn add_missing_data(&mut self, source: &HERelationship) {
self.id.add_missing_data(&source.event);
self.type_ = Some("hf_relationship".to_owned());
self.year.add_missing_data(&source.year);
self.seconds72.add_missing_data(&source.seconds72);
if let Some(relationship) = &source.relationship {
match relationship.parse::<i32>() {
Ok(_number) => {
}
Err(_) => {
self.relationship.add_missing_data(&source.relationship);
}
}
}
self.source_hf_id.add_missing_data(&source.source_hf);
self.target_hf_id.add_missing_data(&source.target_hf);
}
}
impl PartialEq<df_st_core::HistoricalEvent> for HERelationship {
fn eq(&self, other: &df_st_core::HistoricalEvent) -> bool {
self.event == other.id
}
}
impl std::hash::Hash for HERelationship {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.event.hash(state);
}
}
impl Filler<Vec<df_st_core::HistoricalEvent>, HERelationships>
for Vec<df_st_core::HistoricalEvent>
{
fn add_missing_data(&mut self, source: &HERelationships) {
self.add_missing_data(&source.historical_event_relationship);
}
}
impl Filler<IndexMap<u64, df_st_core::HistoricalEvent>, HERelationships>
for IndexMap<u64, df_st_core::HistoricalEvent>
{
fn add_missing_data(&mut self, source: &HERelationships) {
self.add_missing_data(&source.historical_event_relationship);
}
}