pub struct TlsState { /* private fields */ }Expand description
Reloadable TLS state (v0.3 #10). Wraps an ArcSwap<ServerConfig> so the
listener can swap the cert/key pair atomically on SIGHUP without dropping
any in-flight connections. Construct via TlsState::load and pass
Arc<TlsState> to both the accept loop and the SIGHUP handler.
Implementations§
Source§impl TlsState
impl TlsState
Sourcepub fn load(
cert_path: impl Into<PathBuf>,
key_path: impl Into<PathBuf>,
) -> Result<Self, Box<dyn Error + Send + Sync + 'static>>
pub fn load( cert_path: impl Into<PathBuf>, key_path: impl Into<PathBuf>, ) -> Result<Self, Box<dyn Error + Send + Sync + 'static>>
Initial load — fails on parse error. Accepts TLS 1.2 + 1.3.
Sourcepub fn load_tls13_only(
cert_path: impl Into<PathBuf>,
key_path: impl Into<PathBuf>,
) -> Result<Self, Box<dyn Error + Send + Sync + 'static>>
pub fn load_tls13_only( cert_path: impl Into<PathBuf>, key_path: impl Into<PathBuf>, ) -> Result<Self, Box<dyn Error + Send + Sync + 'static>>
v0.5 #32: TLS 1.3-only initial load — fails on parse error.
Reloads via Self::reload also use the 1.3-only loader, so a
SIGHUP hot-swap can’t accidentally re-enable 1.2.
Sourcepub fn acceptor(&self) -> TlsAcceptor
pub fn acceptor(&self) -> TlsAcceptor
Build a fresh TlsAcceptor from the current config. Cheap (one
atomic load + Arc clone). Call this once per accepted connection.
Sourcepub fn reload(&self) -> Result<(), Box<dyn Error + Send + Sync + 'static>>
pub fn reload(&self) -> Result<(), Box<dyn Error + Send + Sync + 'static>>
Re-read the cert + key from disk and atomically swap the active
config. Returns Ok(()) on success and Err(...) if the new pair
failed to parse — the previous config remains in effect either way,
so a bad reload never causes a listener outage.
Auto Trait Implementations§
impl !Freeze for TlsState
impl !RefUnwindSafe for TlsState
impl !UnwindSafe for TlsState
impl Send for TlsState
impl Sync for TlsState
impl Unpin for TlsState
impl UnsafeUnpin for TlsState
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more