fn find_message(&self) -> Option<(usize, usize)> {
        let mut offset = 0;
        let mut message_len = 0;

        while offset < self.buffer.len() {
            // check for a number
            if self.buffer[offset] < 0x3A && self.buffer[offset] >= 0x30 {
                message_len *= 10;
                message_len += (self.buffer[offset] - 0x30) as usize;
                offset += 1;

            // skip newline and carriage return
            } else if self.buffer[offset] == 0xa || self.buffer[offset] == 0xd {
                offset += 1;
            } else {
                break;
            }
        }

        if message_len > 0 && self.buffer.len() >= offset + message_len {
            debug!(
                "Found message in buffer starting at {} with length {}",
                offset, message_len
            );
            Some((offset, message_len))
        } else {
            debug!("Found no complete message in buffer");
            None
        }
    }
/// Find where a message is located
Find where a message is located
Find where a message is located
fn find_message(&self) -> Option<(usize, usize)> {
        let mut offset = 0;
        let mut message_len = 0;
        while offset < self.buffer.len() {
            // check for a number
            if self.buffer[offset] < 0x3A && self.buffer[offset] >= 0x30 {
                message_len *= 10;
                message_len += (self.buffer[offset] - 0x30) as usize;
                offset += 1;
            // skip newline and carriage return
            } else if self.buffer[offset] == 0xa || self.buffer[offset] == 0xd {
                offset += 1;
            } else {
                break;
            }
        }
        if message_len > 0 && self.buffer.len() >= offset + message_len {
            debug!(
                "Found message in buffer starting at {} with length {}",
                offset, message_len
            );
            Some((offset, message_len))
        } else {
            debug!("Found no complete message in buffer");
            None
        }
    }
fn find_message ( & self ) -> Option < ( usize , usize ) > { let mut offset = 0 ; let mut message_len = 0 ; while offset < self . buffer . len ( ) { // check for a number if self . buffer [ offset ] < 0x3A && self . buffer [ offset ] >= 0x30 { message_len *= 10 ; message_len += ( self . buffer [ offset ] - 0x30 ) as usize ; offset += 1 ; // skip newline and carriage return } else if self . buffer [ offset ] == 0xa || self . buffer [ offset ] == 0xd { offset += 1 ; } else { break ; } } if message_len > 0 && self . buffer . len ( ) >= offset + message_len { debug ! ( " " offset message_len ) ; Some ( ( offset , message_len ) ) } else { debug ! ( " " ) ; None } }
Find where a message is located
Find where a message is located
&self