ip_api4rs/model/
ip_response.rs

1use serde::{Deserialize, Serialize};
2
3/// A struct containing the complete response from the Ip Api.
4/// We ask the Api to return every field it can.
5#[derive(Deserialize, Serialize, Debug, PartialEq, Clone)]
6pub struct IpFullResponse {
7    pub query: String,
8    pub status: String,
9    pub continent: String,
10    #[serde(rename = "continentCode")]
11    pub continent_code: String,
12    pub country: String,
13    #[serde(rename = "countryCode")]
14    pub country_code: String,
15    pub region: String,
16    #[serde(rename = "regionName")]
17    pub region_name: String,
18    pub city: String,
19    pub district: String,
20    pub zip: String,
21    pub lat: f32,
22    pub lon: f32,
23    pub timezone: String,
24    pub offset: i32,
25    pub currency: String,
26    pub isp: String,
27    pub org: String,
28    #[serde(rename = "as")]
29    pub asn: String,
30    #[serde(rename = "asname")]
31    pub as_name: String,
32    pub reverse: String,
33    pub mobile: bool,
34    pub proxy: bool,
35    pub hosting: bool,
36}
37
38/// A struct containing the default response from the Ip Api.
39/// We simply give the Api the Ip address with no extra parameters.
40#[derive(Deserialize, Serialize, Debug, PartialEq, Clone)]
41pub struct IpDefaultResponse {
42    pub query: String,
43    pub status: String,
44    pub country: String,
45    #[serde(rename = "countryCode")]
46    pub country_code: String,
47    pub region: String,
48    #[serde(rename = "regionName")]
49    pub region_name: String,
50    pub city: String,
51    pub zip: String,
52    pub lat: f32,
53    pub lon: f32,
54    pub timezone: String,
55    pub isp: String,
56    pub org: String,
57    #[serde(rename = "as")]
58    pub asn: String,
59}
60
61/// A module that contains the error type for the library.
62#[derive(Deserialize, Serialize, Debug, PartialEq, Clone)]
63pub struct ErrorResponse {
64    pub status: String,
65    pub message: String,
66    pub query: String,
67}