diff --git a/hyper-boring/src/lib.rs b/hyper-boring/src/lib.rs index 4c4e569d..53c12a46 100644 --- a/hyper-boring/src/lib.rs +++ b/hyper-boring/src/lib.rs @@ -89,8 +89,14 @@ pub struct HttpsLayer { /// Settings for [`HttpsLayer`] pub struct HttpsLayerSettings { - /// Maximum number of sessions to cache. Session capacity is per session key (domain). - pub session_cache_capacity: usize, + session_cache_capacity: usize, +} + +impl HttpsLayerSettings { + /// Constructs an [`HttpsLayerSettingsBuilder`] for configuring settings + pub fn builder() -> HttpsLayerSettingsBuilder { + HttpsLayerSettingsBuilder(HttpsLayerSettings::default()) + } } impl Default for HttpsLayerSettings { @@ -101,6 +107,22 @@ impl Default for HttpsLayerSettings { } } +/// Builder for [`HttpsLayerSettings`] +pub struct HttpsLayerSettingsBuilder(HttpsLayerSettings); + +impl HttpsLayerSettingsBuilder { + /// Sets maximum number of sessions to cache. Session capacity is per session key (domain). + /// Defaults to 8. + pub fn set_session_cache_capacity(&mut self, capacity: usize) { + self.0.session_cache_capacity = capacity; + } + + /// Consumes the builder, returning a new [`HttpsLayerSettings`] + pub fn build(self) -> HttpsLayerSettings { + self.0 + } +} + impl HttpsLayer { /// Creates a new `HttpsLayer` with default settings. ///