pub fn read(&mut self) -> Result<Option<usize>, std::io::Error> {
        increment_counter!(&Stat::TcpRecv);

        let read_result = match &mut self.stream {
            Some(Stream::Plain(s)) => self.buffer.read_from(s),
            Some(Stream::Tls(s)) => self.buffer.read_from(s),
            Some(Stream::Handshaking(_)) => Ok(None),
            None => Err(Error::new(ErrorKind::Other, "session has no stream")),
        };

        match read_result {
            Ok(Some(0)) => Ok(Some(0)),
            Ok(Some(bytes)) => {
                increment_counter_by!(&Stat::TcpRecvByte, bytes as u64);
                Ok(Some(bytes))
            }
            Ok(None) => Ok(None),
            Err(e) => {
                increment_counter!(&Stat::TcpRecvEx);
                Err(e)
            }
        }
    }
/// Reads from the stream into the session buffer
Reads from the stream into the session buffer
Reads from the stream into the session buffer
pub fn read(&mut self) -> Result<Option<usize>, std::io::Error> {
        increment_counter!(&Stat::TcpRecv);
        let read_result = match &mut self.stream {
            Some(Stream::Plain(s)) => self.buffer.read_from(s),
            Some(Stream::Tls(s)) => self.buffer.read_from(s),
            Some(Stream::Handshaking(_)) => Ok(None),
            None => Err(Error::new(ErrorKind::Other, "session has no stream")),
        };
        match read_result {
            Ok(Some(0)) => Ok(Some(0)),
            Ok(Some(bytes)) => {
                increment_counter_by!(&Stat::TcpRecvByte, bytes as u64);
                Ok(Some(bytes))
            }
            Ok(None) => Ok(None),
            Err(e) => {
                increment_counter!(&Stat::TcpRecvEx);
                Err(e)
            }
        }
    }
pub fn read ( & mut self ) -> Result < Option < usize > , std :: io :: Error > { increment_counter ! ( Stat TcpRecv ) ; let read_result = match & mut self . stream { Some ( Stream :: Plain ( s ) ) => self . buffer . read_from ( s ) , Some ( Stream :: Tls ( s ) ) => self . buffer . read_from ( s ) , Some ( Stream :: Handshaking ( _ ) ) => Ok ( None ) , None => Err ( Error :: new ( ErrorKind :: Other , " " ) ) , } ; match read_result { Ok ( Some ( 0 ) ) => Ok ( Some ( 0 ) ) , Ok ( Some ( bytes ) ) => { increment_counter_by ! ( Stat TcpRecvByte bytes as u64 ) ; Ok ( Some ( bytes ) ) } Ok ( None ) => Ok ( None ) , Err ( e ) => { increment_counter ! ( Stat TcpRecvEx ) ; Err ( e ) } } }
Reads from the stream into the session buffer
Reads from the stream into the session buffer
&mut self
&mut self