Skip to main content

py_string_to_null

Function py_string_to_null 

Source
pub fn py_string_to_null(
    data: &[u8],
    pos: i128,
    max_length: usize,
) -> Option<(Range<usize>, i128)>
Expand description

read_string_to_null(max_length) of the memoryview reader (streams/EndianBinaryReader.py:275-284) at pos over data: the string’s byte range and the new position, or None where it raises (“String not terminated”). re.search(view, pos, pos + max_length) clamps both bounds into 0..=len (py_string_window), so a negative start searches from 0; a hit returns the bytes up to the first NUL in the window and sets the position after that NUL (an absolute index). With no NUL in the window it raises when pos + max_length >= len, and otherwise returns read(max_length), a slice from pos that may hold a NUL or nothing at all (py_string_to_null_found, which a caller that indexed the buffer’s NULs answers with). Implemented by the scaffold.