This commit is contained in:
Eric Rosenberg 2023-12-04 20:07:04 +00:00 committed by Rushil Mehra
parent 2cee0af3d2
commit 870ccd9084
1 changed files with 24 additions and 2 deletions

View File

@ -89,8 +89,14 @@ pub struct HttpsLayer {
/// Settings for [`HttpsLayer`] /// Settings for [`HttpsLayer`]
pub struct HttpsLayerSettings { pub struct HttpsLayerSettings {
/// Maximum number of sessions to cache. Session capacity is per session key (domain). session_cache_capacity: usize,
pub session_cache_capacity: usize, }
impl HttpsLayerSettings {
/// Constructs an [`HttpsLayerSettingsBuilder`] for configuring settings
pub fn builder() -> HttpsLayerSettingsBuilder {
HttpsLayerSettingsBuilder(HttpsLayerSettings::default())
}
} }
impl Default for HttpsLayerSettings { 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 { impl HttpsLayer {
/// Creates a new `HttpsLayer` with default settings. /// Creates a new `HttpsLayer` with default settings.
/// ///