in src/codec/ping.rs [27:44]
fn decode(&self, buffer: &mut Session) -> Result<(), ParseError> {
// no-copy borrow as a slice
let buf: &[u8] = (*buffer).buffer();
// check if we got a CRLF
let mut double_byte_windows = buf.windows(2);
if let Some(response_end) = double_byte_windows.position(|w| w == b"\r\n") {
match &buf[0..response_end] {
b"pong" | b"PONG" => {
let _ = buffer.consume(response_end + 2);
Ok(())
}
_ => Err(ParseError::Unknown),
}
} else {
Err(ParseError::Incomplete)
}
}