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.
Builder::local_addr()
1 parent 45aa624 commit d342c2cCopy full SHA for d342c2c
src/server/server.rs
@@ -629,6 +629,14 @@ impl<E> Builder<AddrIncoming, E> {
629
self.incoming.set_sleep_on_errors(val);
630
self
631
}
632
+
633
+ /// Returns the local address that the server will be bound to.
634
+ ///
635
+ /// This might be useful when knowing the address is required before calling `Builder::serve`,
636
+ /// but the address is not otherwise available (for e.g. when binding to port 0).
637
+ pub fn local_addr(&self) -> SocketAddr {
638
+ self.incoming.local_addr()
639
+ }
640
641
642
// Used by `Server` to optionally watch a `Connection` future.
0 commit comments