/// Reads the requested bytes from the socket with a timeout
Reads the requested bytes from the socket with a timeout
Reads the requested bytes from the socket with a timeout
async fn read_from_socket(
        reader: &mut Box<TlsReadHalf>,
        buf: &mut [u8],
        timeout: Duration,
    ) -> Result<(), ReadError> {
        let read_future = reader.read_exact(buf);
        let ret = tokio::time::timeout(timeout, read_future).await;
        if ret.is_err() {
            return Err(ReadError::SocketReadTimeOut);
        }
        match ret.unwrap() {
            Ok(_) => Ok(()),
            Err(e) => Err(ReadError::SocketReadFailed(e)),
        }
    }
async fn read_from_socket ( reader : & mut Box < TlsReadHalf > , buf : & mut [ u8 ] , timeout : Duration , ) -> Result < ( ) , ReadError > { let read_future = reader . read_exact ( buf ) ; let ret = tokio :: time :: timeout ( timeout , read_future ) . await ; if ret . is_err ( ) { return Err ( ReadError :: SocketReadTimeOut ) ; } match ret . unwrap ( ) { Ok ( _ ) => Ok ( ( ) ) , Err ( e ) => Err ( ReadError :: SocketReadFailed ( e ) ) , } }
Reads the requested bytes from the socket with a timeout
Reads the requested bytes from the socket with a timeout
reader
&mut Box<TlsReadHalf>
buf
&mut [u8]
timeout
Duration