pub struct Server<S, H, R>{ /* private fields */ }Expand description
A high-performance RADIUS server instance.
The Server acts as the central orchestrator of the RADIUS stack, managing
the network lifecycle, request deduplication, and task execution. It is
generic over the secret retrieval logic, the request handler, and the
underlying async runtime.
§Type Parameters
S: Implements SecretProvider to look up shared secrets for incoming packets.H: Implements Handler to define how the server responds to RADIUS requests.R: Implements Runtime to abstract over different async executors (e.g., Tokio or Smol).
Implementations§
Source§impl<S, H, R> Server<S, H, R>
impl<S, H, R> Server<S, H, R>
pub fn new( runtime: R, socket: R::Socket, secret_provider: S, handler: H, ) -> Self
pub fn local_addr(&self) -> Result<SocketAddr>
pub fn with_graceful_shutdown<F>(self, shutdown: F) -> Self
Sourcepub async fn listen_and_serve(self) -> Result<()>
pub async fn listen_and_serve(self) -> Result<()>
Starts the RADIUS server and begins listening for incoming packets.
This is the main entry point of the server. It will run indefinitely until:
- An unrecoverable network error occurs.
- The
shutdown_signal(if provided) is triggered.
§Graceful Shutdown
When a shutdown signal is received, the server stops accepting new packets immediately but waits for all currently processing requests (active tasks) to finish before returning. This ensures no client requests are “dropped” mid-processing.
§Errors
Returns an error if the server fails to retrieve the local address or if the internal run loop encounters a fatal exception.