async fn write_peer_addr(
    peer_addr: &SocketAddr,
    socket: &mut TcpStream,
) -> Result<(), std::io::Error> {
    match peer_addr {
        SocketAddr::V4(peer_addr) => {
            socket.write_u8(IPV4_TYPE_ID).await?;
            socket.write_u16_le(peer_addr.port()).await?;
            socket.write_all(&peer_addr.ip().octets()).await?;
        }
        SocketAddr::V6(peer_addr) => {
            socket.write_u8(IPV6_TYPE_ID).await?;
            socket.write_u16_le(peer_addr.port()).await?;
            socket.write_all(&peer_addr.ip().octets()).await?;
        }
    }
    Ok(())
}
/// Writes socket address of the peer into the socket.
Writes socket address of the peer into the socket.
Writes socket address of the peer into the socket .
async fn write_peer_addr(
    peer_addr: &SocketAddr,
    socket: &mut TcpStream,
) -> Result<(), std::io::Error> {
    match peer_addr {
        SocketAddr::V4(peer_addr) => {
            socket.write_u8(IPV4_TYPE_ID).await?;
            socket.write_u16_le(peer_addr.port()).await?;
            socket.write_all(&peer_addr.ip().octets()).await?;
        }
        SocketAddr::V6(peer_addr) => {
            socket.write_u8(IPV6_TYPE_ID).await?;
            socket.write_u16_le(peer_addr.port()).await?;
            socket.write_all(&peer_addr.ip().octets()).await?;
        }
    }
    Ok(())
}
async fn write_peer_addr ( peer_addr : & SocketAddr , socket : & mut TcpStream , ) -> Result < ( ) , std :: io :: Error > { match peer_addr { SocketAddr :: V4 ( peer_addr ) => { socket . write_u8 ( IPV4_TYPE_ID ) . await ? ; socket . write_u16_le ( peer_addr . port ( ) ) . await ? ; socket . write_all ( & peer_addr . ip ( ) . octets ( ) ) . await ? ; } SocketAddr :: V6 ( peer_addr ) => { socket . write_u8 ( IPV6_TYPE_ID ) . await ? ; socket . write_u16_le ( peer_addr . port ( ) ) . await ? ; socket . write_all ( & peer_addr . ip ( ) . octets ( ) ) . await ? ; } } Ok ( ( ) ) }
Writes socket address of the peer into the socket.
Writes socket address of the peer into the socket .
peer_addr
&SocketAddr
socket
&mut TcpStream
peer_addr
&SocketAddr
socket
&mut TcpStream