[−][src]Function libp2p_core::upgrade::read_varint
pub async fn read_varint<'_>(
socket: &'_ mut impl AsyncRead + Unpin
) -> 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.