tmdb_cli/libs/handlers/
core.rs

1#[macro_export]
2macro_rules! get {
3  ($handler:expr, $req:expr) => {
4    $handler.client.execute($req.build()?).await?.error_for_status()
5  }
6}
7
8pub struct Core {
9  /// The URL/ip to reach tmdb at
10  pub host: String,
11  /// A token to use when authenticating
12  pub token: String,
13  /// A client
14  pub client: reqwest::Client,
15}
16
17impl Core {
18  pub fn new(host: String, token: String) -> Self {
19    // build a reqwest client
20    let client = reqwest::Client::builder()
21      .timeout(std::time::Duration::from_secs(30))
22      .build()
23      .expect("failed to build client");
24      Core { host, token, client }
25  }
26}