/// Reads and returns the next <message hdr, message payload> from the
/// socket. The timeout is for each socket read (header, payload chunks)
/// and not the full message.
Reads and returns the next  from the
socket. The timeout is for each socket read (header, payload chunks)
and not the full message.
Reads and returns the next from the socket . The timeout is for each socket read ( header payload chunks ) and not the full message .
async fn read_one_message(
        reader: &mut Box<TlsReadHalf>,
        timeout: Duration,
    ) -> Result<(TransportHeader, Option<TransportPayload>), ReadError> {
        // Read the hdr
        let mut header_buffer = vec![0u8; TRANSPORT_HEADER_SIZE];
        Self::read_from_socket(reader, &mut header_buffer, timeout).await?;
        let header = Self::unpack_header(header_buffer);
        if header.flags & TRANSPORT_FLAGS_IS_HEARTBEAT != 0 {
            return Ok((header, None));
        }
        // Read the payload in chunks
        let mut payload_buffer = vec![0u8; header.payload_length as usize];
        let mut remaining = header.payload_length as usize;
        let mut cur_offset = 0;
        while remaining > 0 {
            let cur_chunk_size = std::cmp::min(remaining, SOCKET_READ_CHUNK_SIZE);
            assert!(cur_chunk_size <= remaining);
            Self::read_from_socket(
                reader,
                &mut payload_buffer[cur_offset..(cur_offset + cur_chunk_size)],
                timeout,
            )
            .await?;
            remaining -= cur_chunk_size;
            cur_offset += cur_chunk_size;
        }
        let payload = TransportPayload(payload_buffer);
        Ok((header, Some(payload)))
    }
async fn read_one_message ( reader : & mut Box < TlsReadHalf > , timeout : Duration , ) -> Result < ( TransportHeader , Option < TransportPayload > ) , ReadError > { // Read the hdr let mut header_buffer = vec ! [ 0u8 TRANSPORT_HEADER_SIZE ] ; Self :: read_from_socket ( reader , & mut header_buffer , timeout ) . await ? ; let header = Self :: unpack_header ( header_buffer ) ; if header . flags & TRANSPORT_FLAGS_IS_HEARTBEAT != 0 { return Ok ( ( header , None ) ) ; } // Read the payload in chunks let mut payload_buffer = vec ! [ 0u8 header payload_length as usize ] ; let mut remaining = header . payload_length as usize ; let mut cur_offset = 0 ; while remaining > 0 { let cur_chunk_size = std :: cmp :: min ( remaining , SOCKET_READ_CHUNK_SIZE ) ; assert ! ( cur_chunk_size remaining ) ; Self :: read_from_socket ( reader , & mut payload_buffer [ cur_offset .. ( cur_offset + cur_chunk_size ) ] , timeout , ) . await ? ; remaining -= cur_chunk_size ; cur_offset += cur_chunk_size ; } let payload = TransportPayload ( payload_buffer ) ; Ok ( ( header , Some ( payload ) ) ) }
Reads and returns the next <message hdr, message payload> from the
socket.
Reads and returns the next <message hdr message payload > from the socket .
reader
&mut Box<TlsReadHalf>
timeout
Duration