fn read_message(
        &mut self,
        stream: &mut BufStream<TcpStream>,
        buffer: &mut String,
    ) -> Result<Option<String>, String> {
        // Read and return a single message or None or Err
        match stream.read_line(buffer) {
            Ok(_) => {
                // warn!("XXX DEBUG - line read: {:?}", line);
                let res = buffer.clone();
                buffer.clear();
                if res.as_str() == "\n" {
                    return Ok(None);
                }
                return Ok(Some(res));
            }
            Err(ref e) if e.kind() == ErrorKind::WouldBlock => {
                // Not an error, just no messages ready
                return Ok(None);
            }
            Err(e) => {
                error!("{} - Connection Error 1a: {}", self.id, e);
                buffer.clear();
                return Err(format!("{}", e));
            }
        }
    }
/// Read a message from the stream
Read a message from the stream
Read a message from the stream
fn read_message(
        &mut self,
        stream: &mut BufStream<TcpStream>,
        buffer: &mut String,
    ) -> Result<Option<String>, String> {
        // Read and return a single message or None or Err
        match stream.read_line(buffer) {
            Ok(_) => {
                // warn!("XXX DEBUG - line read: {:?}", line);
                let res = buffer.clone();
                buffer.clear();
                if res.as_str() == "\n" {
                    return Ok(None);
                }
                return Ok(Some(res));
            }
            Err(ref e) if e.kind() == ErrorKind::WouldBlock => {
                // Not an error, just no messages ready
                return Ok(None);
            }
            Err(e) => {
                error!("{} - Connection Error 1a: {}", self.id, e);
                buffer.clear();
                return Err(format!("{}", e));
            }
        }
    }
fn read_message ( & mut self , stream : & mut BufStream < TcpStream > , buffer : & mut String , ) -> Result < Option < String > , String > { // Read and return a single message or None or Err match stream . read_line ( buffer ) { Ok ( _ ) => { // warn!("XXX DEBUG - line read: {:?}", line); let res = buffer . clone ( ) ; buffer . clear ( ) ; if res . as_str ( ) == " \n " { return Ok ( None ) ; } return Ok ( Some ( res ) ) ; } Err ( ref e ) if e . kind ( ) == ErrorKind :: WouldBlock => { // Not an error, just no messages ready return Ok ( None ) ; } Err ( e ) => { error ! ( " " self id e ) ; buffer . clear ( ) ; return Err ( format ! ( " " e ) ) ; } } }
Read a message from the stream
Read a message from the stream
&mut self
stream
&mut BufStream<TcpStream>
buffer
&mut String