Skip to main content

bind

Function bind 

Source
pub async fn bind(config: &ServerConfig) -> Result<TcpListener>
Expand description

Bind a TCP listener for the given configuration without starting the Axum server.

The host field accepts IPv4 literals, IPv6 literals (no brackets needed), and hostnames (resolved via DNS).

Useful for tests that need to assert binding behavior deterministically without spawning the full server task.

ยงErrors

Returns Err if the host cannot be resolved, the port is already in use, or listening fails.