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

pub async fn read_one(
    socket: &'_ mut impl Unpin + AsyncRead,
    max_size: usize
) -> Result<Vec<u8, Global>, ReadOneError>

Reads a length-prefixed message from the given socket.

The max_size parameter is the maximum size in bytes of the message that we accept. This is necessary in order to avoid DoS attacks where the remote sends us a message of several gigabytes.

Note: Assumes that a variable-length prefix indicates the length of the message. This is compatible with what write_one does.