Skip to main content

read_lengthed_bytes

Function read_lengthed_bytes 

Source
fn read_lengthed_bytes<'a>(
    data: &mut &'a [u8],
    tag: Tag,
    first: Tag,
) -> &'a [u8] 
Expand description

Read a byte slice preceded by its length, the width of the length prefix given by the tag’s distance from first, its kind’s *Tiny tag.

Each arm reads the prefix at a constant width, which is a plain load; deriving the width and reading that many bytes measured twice as slow on long payloads.

§Safety

The contents are whatever push_lengthed_bytes wrote, so a caller may treat them as UTF-8 only for a String tag.