Skip to main content

parse_netdoc_multiple_with_offsets

Function parse_netdoc_multiple_with_offsets 

Source
pub fn parse_netdoc_multiple_with_offsets<D: NetdocParseable>(
    input: &ParseInput<'_>,
) -> Result<Vec<(D, usize, usize)>, ParseError>
Expand description

Parse multiple network documents, also returning their offsets - toplevel entrypoint

Each returned document is accompanied by the byte offsets of its start and end.

(The netdoc metaformat does not allow anything in between subsequent documents in a file, so the end of one document is the start of the next.)

This returns byte offsets rather than string slices, because the caller can always convert the offsets into string slices, but it is not straightforward to convert string slices borrowed from some input string into offsets, in a way that is obviously correct without nightly str::substr_range.

Interfacing code can assume that slicing the input string with the returned usize values will not cause an out-of-bounds error, meaning runtime checks are not necessary there.