1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! Connector with hyper backend.

pub mod hyper;

use std::fmt::Debug;
use std::pin::Pin;

use futures::Future;
use telegram_bot_raw::{HttpRequest, HttpResponse};

use crate::errors::Error;

pub trait Connector: Debug + Send + Sync {
    fn request(
        &self,
        token: &str,
        req: HttpRequest,
    ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Error>> + Send>>;
}

pub fn default_connector() -> Box<dyn Connector> {
    hyper::default_connector().unwrap()
}