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

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.