#[non_exhaustive]pub struct ServerHandle {
pub http_addr: Option<SocketAddr>,
pub https_addr: Option<SocketAddr>,
pub cert_reloader: Option<Arc<ReloadableCertResolver>>,
}Expand description
Handle an embedder holds to interact with a running server.
§Why it doesn’t expose a .restart()
The brief is specific: “restart は server crate の内部責務にしない”
(restart is not a server-crate responsibility). A ServerHandle
carries read-only introspection and a shutdown signal — nothing
more. If a change requires the listener to rebind a new port, the
embedder tears the server down and constructs a fresh one.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.http_addr: Option<SocketAddr>Address the HTTP listener is bound to, if any.
https_addr: Option<SocketAddr>Address the HTTPS listener is bound to, if any.
cert_reloader: Option<Arc<ReloadableCertResolver>>Hot-reload handle for TLS certificates (RFC 020).
Some when an HTTPS listener is active with a reloadable cert.
None for HTTP-only servers.
Implementations§
Source§impl ServerHandle
impl ServerHandle
Sourcepub fn reload_tls_certs(
&self,
cert_path: &str,
key_path: &str,
) -> Result<(), String>
pub fn reload_tls_certs( &self, cert_path: &str, key_path: &str, ) -> Result<(), String>
Reload the TLS certificate and private key from the given PEM files.
Returns Ok(()) if the swap succeeded; the new cert is used for all
TLS handshakes started after this call. On error, the old cert remains
active.
§Errors
Returns an error string if:
- No HTTPS listener is active (
cert_reloaderisNone). - The new cert or key fails to parse.
Trait Implementations§
Source§impl Clone for ServerHandle
impl Clone for ServerHandle
Source§fn clone(&self) -> ServerHandle
fn clone(&self) -> ServerHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more