pub fn peer_addr(&self) -> io::Result<PeerAddr> {
        match &self.stream {
            Stream::Tcp(s) => s.peer_addr().map(PeerAddr::Tcp),
            #[cfg(unix)]
            Stream::Unix(s) => {
                s.peer_addr()
                .map(|a| a.as_pathname().map(|p| p.to_owned()))
                .map(PeerAddr::Unix)
            }
        }
    }
/// Returns the remote address that this stream is connected to.
///
/// Note: even on non-unix platforms (Windows)
/// [`PeerAddr`](enum.PeerAddr.html) still contains `Unix` option so you
/// don't have to use conditional compilation when matching.
///
/// ## Examples
///
/// ```ignore
/// let peer = stream.peer_addr()?;
/// match peer.peer_addr()? {
///     PeerAddr::Tcp(addr) => println!("TCP addr {}", addr),
///     PeerAddr::Unix(None) => println!("Unnamed unix socket"),
///     PeerAddr::Unix(Some(path)) => println!("Unix {}", path.display()),
/// }
/// ```
Returns the remote address that this stream is connected to.
Note: even on non-unix platforms (Windows)
[`PeerAddr`](enum.PeerAddr.html) still contains `Unix` option so you
don't have to use conditional compilation when matching.
Returns the remote address that this stream is connected to . Note : even on non - unix platforms ( Windows ) [ ` PeerAddr ` ] ( enum . PeerAddr . html ) still contains ` Unix ` option so you don ' t have to use conditional compilation when matching .
pub fn peer_addr(&self) -> io::Result<PeerAddr> {
        match &self.stream {
            Stream::Tcp(s) => s.peer_addr().map(PeerAddr::Tcp),
            #[cfg(unix)]
            Stream::Unix(s) => {
                s.peer_addr()
                .map(|a| a.as_pathname().map(|p| p.to_owned()))
                .map(PeerAddr::Unix)
            }
        }
    }
pub fn peer_addr ( & self ) -> io :: Result < PeerAddr > { match & self . stream { Stream :: Tcp ( s ) => s . peer_addr ( ) . map ( PeerAddr :: Tcp ) , # [ cfg ( unix ) ] Stream :: Unix ( s ) => { s . peer_addr ( ) . map ( | a | a . as_pathname ( ) . map ( | p | p . to_owned ( ) ) ) . map ( PeerAddr :: Unix ) } } }
Returns the remote address that this stream is connected to.
Returns the remote address that this stream is connected to .
&self
&self
examples
```ignore
let peer = stream.peer_addr()?;
match peer.peer_addr(). {
PeerAddr::Tcp(addr) => println!("TCP addr {}", addr),
PeerAddr::Unix(None) => println!("Unnamed unix socket"),
PeerAddr::Unix(Some(path)) => println!("Unix {}", path.display()),
}
```
` ` ` ignore let peer = stream . peer_addr () ? ; match peer . peer_addr () . { PeerAddr :: Tcp ( addr ) = > println! ( " TCP addr {} " addr ) PeerAddr :: Unix ( None ) = > println! ( " Unnamed unix socket " ) PeerAddr :: Unix ( Some ( path )) = > println! ( " Unix {} " path . display () ) } ` ` `