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
//! # World Time Wrapper
//!
//! This is a simple wrapper for the [World Time API](https://worldtimeapi.org/api/timezone/).
//!
//! ## Usage
//!
//! To use this crate, add `worldtimeapi` to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! worldtimeapi = "0.5.3"
//! ```
//!
//! Then create a client for an endpoint (currently they only offer "ip" and "timezone"):
//!
//! ```rust
//! use std::collections::HashMap;
//!
//! use worldtimeapi::service::{Client, Endpoint};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), reqwest::Error> {
//! let client = Client::new(Endpoint::Timezone).await?;
//!
//! let mut payload = HashMap::new();
//! payload.insert("area", "America");
//! payload.insert("location", "New_York");
//!
//! let result = client.get(payload).await?;
//! println!("{}", result.datetime());
//! Ok(())
//! }
//! ```
//!
//! To get a list of regions and locations, use the `regions` method:
//!
//! ```rust
//! use worldtimeapi::service::{Client, Endpoint};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), reqwest::Error> {
//! let client = Client::new(Endpoint::Timezone).await?;
//! let regions = client.regions();
//! println!("{:?}", regions);
//! Ok(())
//! }
//! ```
//!
/// A collection of JSON responses from the [World Time API](https://worldtimeapi.org/api).
/// The client for the [World Time API](https://worldtimeapi.org/api).