We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0ff6213 commit 5668fb9Copy full SHA for 5668fb9
src/server/server.rs
@@ -594,6 +594,14 @@ impl<E> Builder<AddrIncoming, E> {
594
self.incoming.set_sleep_on_errors(val);
595
self
596
}
597
+
598
+ /// Returns the local address that the server will be bound to.
599
+ ///
600
+ /// This might be useful when knowing the address is required before calling `Builder::serve`,
601
+ /// but the address is not otherwise available (for e.g. when binding to port 0).
602
+ pub fn local_addr(&self) -> SocketAddr {
603
+ self.incoming.local_addr()
604
+ }
605
606
607
// Used by `Server` to optionally watch a `Connection` future.
0 commit comments