Skip to main content

parse_string

Function parse_string 

Source
pub fn parse_string<S: Source, P: CountPrefix>(
    r: &mut S,
) -> Result<String, BitError>
Expand description

Reads a P byte-length prefix, then that many bytes, UTF-8-validated.

No pre-allocation from the untrusted length — bytes are pushed as read, bounded by the input, so a hostile huge prefix is a fast UnexpectedEof, not an allocation.

§Errors

UnexpectedEof when the input is shorter than the prefix promises; Convert on invalid UTF-8.