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
#![allow(clippy::derive_partial_eq_without_eq)]
use serde::Serialize;
use serde_with::skip_serializing_none;
use std::net::{IpAddr, Ipv6Addr};
#[derive(PartialEq, Debug, Clone, Serialize)]
pub struct Country {
pub short_name: String,
pub long_name: String,
}
#[skip_serializing_none]
#[derive(PartialEq, Debug, Clone, Serialize)]
pub struct LocationRecord {
pub ip: IpAddr,
pub latitude: Option<f32>,
pub longitude: Option<f32>,
pub country: Option<Country>,
pub region: Option<String>,
pub city: Option<String>,
pub isp: Option<String>,
pub domain: Option<String>,
pub zip_code: Option<String>,
pub time_zone: Option<String>,
pub net_speed: Option<String>,
pub idd_code: Option<String>,
pub area_code: Option<String>,
pub weather_station_code: Option<String>,
pub weather_station_name: Option<String>,
pub mcc: Option<String>,
pub mnc: Option<String>,
pub mobile_brand: Option<String>,
pub elevation: Option<String>,
pub usage_type: Option<String>,
pub address_type: Option<String>,
pub category: Option<String>,
}
impl LocationRecord {
pub fn to_json(&self) -> String {
serde_json::to_string(&self).unwrap()
}
}
impl Default for LocationRecord {
fn default() -> Self {
LocationRecord {
ip: IpAddr::V6(Ipv6Addr::UNSPECIFIED),
latitude: None,
longitude: None,
country: None,
region: None,
city: None,
isp: None,
domain: None,
zip_code: None,
time_zone: None,
net_speed: None,
idd_code: None,
area_code: None,
weather_station_code: None,
weather_station_name: None,
mcc: None,
mnc: None,
mobile_brand: None,
elevation: None,
usage_type: None,
address_type: None,
category: None,
}
}
}