async fn read_socket_addr(socket: &mut TcpStream) -> crate::Result<SocketAddr> {
    let addr_type = socket.read_u8().await?;
    let port = socket.read_u16_le().await?;

    match addr_type {
        IPV4_TYPE_ID => {
            let addr = read_ipv4_address(socket).await?;
            Ok(SocketAddr::new(IpAddr::V4(addr), port))
        }
        IPV6_TYPE_ID => {
            let addr = read_ipv6_address(socket).await?;
            Ok(SocketAddr::new(IpAddr::V6(addr), port))
        }
        _ => Err(RequestError::InvalidPeerAddressType(addr_type).into()),
    }
}
/// Reads peer address from the specified socket.
Reads peer address from the specified socket.
Reads peer address from the specified socket .
async fn read_socket_addr(socket: &mut TcpStream) -> crate::Result<SocketAddr> {
    let addr_type = socket.read_u8().await?;
    let port = socket.read_u16_le().await?;
    match addr_type {
        IPV4_TYPE_ID => {
            let addr = read_ipv4_address(socket).await?;
            Ok(SocketAddr::new(IpAddr::V4(addr), port))
        }
        IPV6_TYPE_ID => {
            let addr = read_ipv6_address(socket).await?;
            Ok(SocketAddr::new(IpAddr::V6(addr), port))
        }
        _ => Err(RequestError::InvalidPeerAddressType(addr_type).into()),
    }
}
async fn read_socket_addr ( socket : & mut TcpStream ) -> crate :: Result < SocketAddr > { let addr_type = socket . read_u8 ( ) . await ? ; let port = socket . read_u16_le ( ) . await ? ; match addr_type { IPV4_TYPE_ID => { let addr = read_ipv4_address ( socket ) . await ? ; Ok ( SocketAddr :: new ( IpAddr :: V4 ( addr ) , port ) ) } IPV6_TYPE_ID => { let addr = read_ipv6_address ( socket ) . await ? ; Ok ( SocketAddr :: new ( IpAddr :: V6 ( addr ) , port ) ) } _ => Err ( RequestError :: InvalidPeerAddressType ( addr_type ) . into ( ) ) , } }
Reads peer address from the specified socket.
Reads peer address from the specified socket .
socket
&mut TcpStream
socket
&mut TcpStream