pub struct DynamicServerConfig { /* private fields */ }Expand description
Atomically swappable wrapper around a rustls::ServerConfig.
Cheap to clone (one Arc bump); cheap to read (lock-free); the
only expensive operation is reload_from, which re-parses cert
files.
Implementations§
Source§impl DynamicServerConfig
impl DynamicServerConfig
Sourcepub fn from_tls_config(cfg: &TlsConfig) -> Result<Arc<Self>, TlsError>
pub fn from_tls_config(cfg: &TlsConfig) -> Result<Arc<Self>, TlsError>
Build a fresh DynamicServerConfig from a TlsConfig. Reads
cert + key + optional client-CA paths immediately.
§Errors
Propagates the underlying TlsError from
TlsConfig::build_server_config.
Sourcepub fn current(&self) -> Arc<ServerConfig>
pub fn current(&self) -> Arc<ServerConfig>
Snapshot the current ServerConfig. The returned Arc is
independent of subsequent reload_from
calls — already-running handshakes against this snapshot are
unaffected by a concurrent reload.
Sourcepub fn reload_from(&self, cfg: &TlsConfig) -> Result<(), TlsError>
pub fn reload_from(&self, cfg: &TlsConfig) -> Result<(), TlsError>
Re-read cert + key + optional client-CA from disk and swap the
new ServerConfig in atomically. On error the previous config
is left in place and the error is returned to the caller.
Reload is a no-op semantically when the inputs haven’t changed
— but rustls doesn’t expose a content-equality hash on
ServerConfig, so we just rebuild unconditionally. Callers
that want to skip identical reloads should diff mtimes upstream.
§Errors
Propagates the underlying TlsError from
TlsConfig::build_server_config.