fn parse_escape(remaining_octets: &[u8]) -> Result<(u8, usize), Error> {
    if remaining_octets.is_empty() {
        Err(Error::InvalidEscape)
    } else if remaining_octets[0].is_ascii_digit() {
        if remaining_octets.len() < 3
            || !remaining_octets[1].is_ascii_digit()
            || !remaining_octets[2].is_ascii_digit()
        {
            Err(Error::InvalidEscape)
        } else {
            let hundreds = (remaining_octets[0] - b'0') as usize;
            let tens = (remaining_octets[1] - b'0') as usize;
            let ones = (remaining_octets[2] - b'0') as usize;
            let value = 100 * hundreds + 10 * tens + ones;
            if value > 255 {
                Err(Error::InvalidEscape)
            } else {
                Ok((value as u8, 3))
            }
        }
    } else {
        Ok((remaining_octets[0], 1))
    }
}
/// Parses an escape sequence. We expect `remaining_octets` to start
/// with the octet immediately *after* the backslash that introduces the
/// escape sequence.
Parses an escape sequence. We expect `remaining_octets` to start
with the octet immediately *after* the backslash that introduces the
escape sequence.
Parses an escape sequence . We expect ` remaining_octets ` to start with the octet immediately * after * the backslash that introduces the escape sequence .
fn parse_escape(remaining_octets: &[u8]) -> Result<(u8, usize), Error> {
    if remaining_octets.is_empty() {
        Err(Error::InvalidEscape)
    } else if remaining_octets[0].is_ascii_digit() {
        if remaining_octets.len() < 3
            || !remaining_octets[1].is_ascii_digit()
            || !remaining_octets[2].is_ascii_digit()
        {
            Err(Error::InvalidEscape)
        } else {
            let hundreds = (remaining_octets[0] - b'0') as usize;
            let tens = (remaining_octets[1] - b'0') as usize;
            let ones = (remaining_octets[2] - b'0') as usize;
            let value = 100 * hundreds + 10 * tens + ones;
            if value > 255 {
                Err(Error::InvalidEscape)
            } else {
                Ok((value as u8, 3))
            }
        }
    } else {
        Ok((remaining_octets[0], 1))
    }
}
fn parse_escape ( remaining_octets : & [ u8 ] ) -> Result < ( u8 , usize ) , Error > { if remaining_octets . is_empty ( ) { Err ( Error :: InvalidEscape ) } else if remaining_octets [ 0 ] . is_ascii_digit ( ) { if remaining_octets . len ( ) < 3 || ! remaining_octets [ 1 ] . is_ascii_digit ( ) || ! remaining_octets [ 2 ] . is_ascii_digit ( ) { Err ( Error :: InvalidEscape ) } else { let hundreds = ( remaining_octets [ 0 ] - b'0' ) as usize ; let tens = ( remaining_octets [ 1 ] - b'0' ) as usize ; let ones = ( remaining_octets [ 2 ] - b'0' ) as usize ; let value = 100 * hundreds + 10 * tens + ones ; if value > 255 { Err ( Error :: InvalidEscape ) } else { Ok ( ( value as u8 , 3 ) ) } } } else { Ok ( ( remaining_octets [ 0 ] , 1 ) ) } }
Parses an escape sequence.
Parses an escape sequence .
remaining_octets
&[u8]
remaining_octets
&[u8]