fn parse_chunk(octets: &[u8], start: usize, builder: &mut NameBuilder) -> Result<Chunk, Error> {
    let mut index = start;
    let mut finished = false;

    while !finished && index < octets.len() {
        let len = octets[index];
        if len & 0xc0 == 0xc0 {
            let pointer = parse_pointer(octets, start, index)?;
            return Ok(Chunk::Pointer(index + 2 - start, pointer));
        } else if len > (MAX_LABEL_LEN as u8) {
            return Err(Error::LabelTooLong);
        } else if len == 0 {
            finished = true;
            index += 1;
        } else {
            let content_start = index + 1;
            let content_end = index + 1 + len as usize;
            if content_end > octets.len() {
                return Err(Error::UnexpectedEom);
            }
            builder.try_push_slice(&octets[content_start..content_end])?;
            builder.next_label()?;
            index = content_end;
        }
    }

    if !finished {
        Err(Error::UnexpectedEom)
    } else {
        Ok(Chunk::Last(index - start))
    }
}
/// Parses a chunk of a compressed on-the-wire name in `octets` starting
/// at index `start`. Labels contained in the chunk are written to the
/// passed [`NameBuilder`]. On success, details about the chunk are
/// returned. Note that on failure, the state of the [`NameBuilder`] is
/// undefined, since the calling code above doesn't need to try to
/// recover.
Parses a chunk of a compressed on-the-wire name in `octets` starting
at index `start`. Labels contained in the chunk are written to the
passed [`NameBuilder`]. On success, details about the chunk are
returned. Note that on failure, the state of the [`NameBuilder`] is
undefined, since the calling code above doesn't need to try to
recover.
Parses a chunk of a compressed on - the - wire name in ` octets ` starting at index ` start ` . Labels contained in the chunk are written to the passed [ ` NameBuilder ` ] . On success details about the chunk are returned . Note that on failure the state of the [ ` NameBuilder ` ] is undefined since the calling code above doesn ' t need to try to recover .
fn parse_chunk(octets: &[u8], start: usize, builder: &mut NameBuilder) -> Result<Chunk, Error> {
    let mut index = start;
    let mut finished = false;
    while !finished && index < octets.len() {
        let len = octets[index];
        if len & 0xc0 == 0xc0 {
            let pointer = parse_pointer(octets, start, index)?;
            return Ok(Chunk::Pointer(index + 2 - start, pointer));
        } else if len > (MAX_LABEL_LEN as u8) {
            return Err(Error::LabelTooLong);
        } else if len == 0 {
            finished = true;
            index += 1;
        } else {
            let content_start = index + 1;
            let content_end = index + 1 + len as usize;
            if content_end > octets.len() {
                return Err(Error::UnexpectedEom);
            }
            builder.try_push_slice(&octets[content_start..content_end])?;
            builder.next_label()?;
            index = content_end;
        }
    }
    if !finished {
        Err(Error::UnexpectedEom)
    } else {
        Ok(Chunk::Last(index - start))
    }
}
fn parse_chunk ( octets : & [ u8 ] , start : usize , builder : & mut NameBuilder ) -> Result < Chunk , Error > { let mut index = start ; let mut finished = false ; while ! finished && index < octets . len ( ) { let len = octets [ index ] ; if len & 0xc0 == 0xc0 { let pointer = parse_pointer ( octets , start , index ) ? ; return Ok ( Chunk :: Pointer ( index + 2 - start , pointer ) ) ; } else if len > ( MAX_LABEL_LEN as u8 ) { return Err ( Error :: LabelTooLong ) ; } else if len == 0 { finished = true ; index += 1 ; } else { let content_start = index + 1 ; let content_end = index + 1 + len as usize ; if content_end > octets . len ( ) { return Err ( Error :: UnexpectedEom ) ; } builder . try_push_slice ( & octets [ content_start .. content_end ] ) ? ; builder . next_label ( ) ? ; index = content_end ; } } if ! finished { Err ( Error :: UnexpectedEom ) } else { Ok ( Chunk :: Last ( index - start ) ) } }
Parses a chunk of a compressed on-the-wire name in `octets` starting
at index `start`.
Parses a chunk of a compressed on - the - wire name in ` octets ` starting at index ` start ` .
octets
&[u8]
start
usize
builder
&mut NameBuilder
octets
&[u8]
start
usize
builder
&mut NameBuilder