diff --git a/src/net.rs b/src/net.rs index 692892a..d38ffac 100644 --- a/src/net.rs +++ b/src/net.rs @@ -72,7 +72,7 @@ impl Reactor { &self, source: &Source, direction: usize, - cx: &mut Context<'_>, + cx: &Context<'_>, ) -> Poll> { if source.triggered[direction].load(Ordering::Acquire) { return Poll::Ready(Ok(())); @@ -189,7 +189,7 @@ impl TcpStream { &self, direction: usize, mut f: impl FnMut() -> io::Result, - cx: &mut Context<'_>, + cx: &Context<'_>, ) -> Poll> { loop { if self diff --git a/src/server.rs b/src/server.rs index 1544ae4..87923b2 100644 --- a/src/server.rs +++ b/src/server.rs @@ -368,6 +368,15 @@ impl Server { self } + /// Get the local address of the bound socket + pub fn local_addr(&self) -> Option> { + let listener = self.listener.as_ref()?; + let addr = listener + .local_addr() + .map_err(|_e| io::Error::new(io::ErrorKind::Other, "Server::bind not called yet")); + Some(addr) + } + fn configure(&self, http: &mut Http) { macro_rules! configure { ($self:ident, $other:expr, [$($option:ident),* $(,)?], [$($other_option:ident => $this_option:ident),* $(,)?]) => {{