pub async fn serve(
state: AppState,
addr: SocketAddr,
) -> Result<(SocketAddr, impl Future<Output = Result<()>>)>Expand description
Bind and serve. Returns the bound address, which matters when the caller asked for port 0.
Creates the unique indexes before binding. That used to live in the binary, which meant an
embedder got a server whose _User collection accepted duplicate usernames: the write
succeeded, no error reached the client, and the collision only surfaced later as two accounts
answering to one name. Index creation is part of boot upstream too, so doing it here matches
rather than extends. A failure is fatal for the same reason it is fatal upstream.