Function libp2p::core::upgrade::read_varint
source · pub async fn read_varint(
socket: &mut impl AsyncRead + Unpin
) -> impl Future<Output = Result<usize, Error>>
Expand description
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.