termii_rust/async_impl/rest/
termii.rs

1use std::sync::Arc;
2
3use rest::{insights, switch, token};
4
5use crate::async_impl::{http::client, rest};
6
7#[derive(Debug)]
8#[allow(dead_code)]
9pub struct Termii<'a> {
10    pub token: token::Token<'a>,
11    pub insights: insights::Insights<'a>,
12    pub switch: switch::Switch<'a>,
13}
14
15impl<'a> Termii<'a> {
16    pub fn new(api_key: &str) -> Termii {
17        let http_client = Arc::new(
18            client::HttpClient::new(20).expect("Can not create new instance of the http client."),
19        );
20
21        let token = token::Token::new(api_key, Arc::clone(&http_client));
22        let switch = switch::Switch::new(api_key, Arc::clone(&http_client));
23        let insights = insights::Insights::new(api_key, Arc::clone(&http_client));
24
25        println!("{}", Arc::strong_count(&http_client));
26
27        let termii = Termii {
28            insights: insights, 
29            token: token,
30            switch: switch,
31        };
32
33        termii
34    }
35}