1#![warn(missing_docs)]
3
4use std::fmt;
5use tokio_boring::SslStream;
6
7mod v1;
8
9pub use self::v1::*;
10
11pub struct HttpsLayerSettings {
13 session_cache_capacity: usize,
14}
15
16impl HttpsLayerSettings {
17 #[must_use]
19 pub fn builder() -> HttpsLayerSettingsBuilder {
20 HttpsLayerSettingsBuilder(HttpsLayerSettings::default())
21 }
22}
23
24impl Default for HttpsLayerSettings {
25 fn default() -> Self {
26 Self {
27 session_cache_capacity: 8,
28 }
29 }
30}
31
32pub struct HttpsLayerSettingsBuilder(HttpsLayerSettings);
34
35impl HttpsLayerSettingsBuilder {
36 pub fn set_session_cache_capacity(&mut self, capacity: usize) {
39 self.0.session_cache_capacity = capacity;
40 }
41
42 #[must_use]
44 pub fn build(self) -> HttpsLayerSettings {
45 self.0
46 }
47}
48
49pub enum MaybeHttpsStream<T> {
51 Http(T),
53 Https(SslStream<T>),
55}
56
57impl<T> fmt::Debug for MaybeHttpsStream<T> {
58 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
59 match *self {
60 MaybeHttpsStream::Http(..) => f.pad("Http(..)"),
61 MaybeHttpsStream::Https(..) => f.pad("Https(..)"),
62 }
63 }
64}