Function libp2p::core::upgrade::read_varint[][src]

pub async fn read_varint(
    socket: &'_ mut impl Unpin + AsyncRead
) -> Result<usize, Error>

Reads a variable-length integer from the socket.

As a special exception, if the socket is empty and EOFs right at the beginning, then we return Ok(0).

Note: This function reads bytes one by one from the socket. It is therefore encouraged to use some sort of buffering mechanism.