Fastly Compute C++ SDK
Loading...
Searching...
No Matches
geo.h
Go to the documentation of this file.
1#ifndef FASTLY_GEO_H
2#define FASTLY_GEO_H
3
4#include <fastly/error.h>
5#include <fastly/sdk-sys.h>
6#include <optional>
7#include <string>
8#include <string_view>
9
10namespace fastly::geo {
11
12// Straight up re-export these enums. They're shared types.
13using fastly::sys::geo::ConnSpeed;
14using fastly::sys::geo::ConnType;
15using fastly::sys::geo::Continent;
16using fastly::sys::geo::ProxyDescription;
17using fastly::sys::geo::ProxyType;
18
19class Geo;
20
38
42class UtcOffset {
43 friend Geo;
44
45public:
48 int8_t whole_hours();
49
52 int16_t whole_minutes();
53
57
60 int32_t whole_seconds();
61
65
67 bool is_utc();
68
71
74
75private:
76 rust::Box<fastly::sys::geo::UtcOffset> offset;
77 UtcOffset(rust::Box<fastly::sys::geo::UtcOffset> o) : offset(std::move(o)) {};
78};
79
81class Geo {
82 friend fastly::expected<std::optional<Geo>> geo_lookup(std::string_view ip);
83
84public:
88 std::string as_name();
89
93 uint32_t as_number();
94
99 uint16_t area_code();
100
102 std::string city();
103
105 ConnSpeed conn_speed();
106
108 ConnType conn_type();
109
111 Continent continent();
112
124 std::string country_code();
125
133 std::string country_code3();
134
140 std::string country_name();
141
148 double latitude();
149
157 double longitude();
158
161 int64_t metro_code();
162
172 std::string postal_code();
173
175 ProxyDescription proxy_description();
176
178 ProxyType proxy_type();
179
220 std::optional<std::string> region();
221
226 std::optional<UtcOffset> utc_offset();
227
228private:
229 rust::Box<fastly::sys::geo::Geo> geo;
230 Geo(rust::Box<fastly::sys::geo::Geo> g) : geo(std::move(g)) {};
231};
232
233} // namespace fastly::geo
234
235#endif
The geographic data associated with a particular IP address.
Definition geo.h:81
std::string as_name()
ConnSpeed conn_speed()
Connection speed.
std::string country_code3()
uint32_t as_number()
friend fastly::expected< std::optional< Geo > > geo_lookup(std::string_view ip)
std::optional< std::string > region()
std::optional< UtcOffset > utc_offset()
std::string country_name()
ConnType conn_type()
Connection type.
std::string city()
City or town name.
std::string country_code()
Continent continent()
Continent.
uint16_t area_code()
int64_t metro_code()
double longitude()
ProxyType proxy_type()
Client proxy type.
std::string postal_code()
ProxyDescription proxy_description()
Client proxy description.
bool is_positive()
Check if the offset is positive, or east of UTC.
bool is_negative()
Check if the offset is negative, or west of UTC.
bool is_utc()
Check if the offset is exactly UTC.
tl::expected< T, FastlyError > expected
Definition error.h:25
Definition geo.h:10
fastly::expected< std::optional< Geo > > geo_lookup(std::string_view ip)