mod config;
mod connection;
#[cfg(feature = "http-server")]
mod server;
pub use self::config::HttpConfig;
#[cfg(feature = "http-server")]
pub use self::server::Server;
use self::connection::HttpConnection;
use crate::connector::{self, Connectable, Connection};
#[derive(Clone, Default, Debug)]
pub(crate) struct HttpConnector(HttpConfig);
impl HttpConnector {
pub fn create(config: &HttpConfig) -> Box<dyn Connectable> {
Box::new(HttpConnector(config.clone()))
}
}
impl Connectable for HttpConnector {
fn box_clone(&self) -> Box<dyn Connectable> {
Box::new(HttpConnector(self.0.clone()))
}
fn connect(&self) -> Result<Box<dyn Connection>, connector::Error> {
Ok(Box::new(HttpConnection::open(&self.0)?))
}
}
impl Into<Box<dyn Connectable>> for HttpConnector {
fn into(self) -> Box<dyn Connectable> {
Box::new(self)
}
}