use std::time::Duration;
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub enum HttpsVerify {
True,
False,
Path(String)
}
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub enum HttpsCert {
None,
CertKey{cert: String, key: String}
}
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub struct HttpConfig {
pub timeout: Option<Duration>,
pub verify: HttpsVerify,
pub cert: HttpsCert
}
pub struct HttpConfigBuilder {
timeout: Option<Duration>,
verify: HttpsVerify,
cert: HttpsCert
}
impl HttpConfigBuilder {
pub fn default() -> HttpConfigBuilder {
HttpConfigBuilder{
timeout: None,
verify: HttpsVerify::True,
cert: HttpsCert::None
}
}
pub fn timeout(mut self, value: Duration) -> HttpConfigBuilder {
self.timeout = Some(value);
self
}
pub fn verify(mut self, value: HttpsVerify) -> HttpConfigBuilder {
self.verify = value;
self
}
pub fn cert(mut self, value: HttpsCert) -> HttpConfigBuilder {
self.cert = value;
self
}
pub fn build(self) -> HttpConfig {
HttpConfig{
timeout: self.timeout,
verify: self.verify,
cert: self.cert
}
}
}