Skip to main content

py_read

Function py_read 

Source
pub fn py_read(len: usize, pos: i128, size: i64) -> (Range<usize>, i128)
Expand description

The memoryview reader’s read(size) at pos over len bytes (streams/EndianBinaryReader.py:249-256), with Python’s arithmetic: size 0 reads nothing and leaves the position; size -1 reads to the end; any other size is the slice view[pos : pos + size], where a negative index counts from the end, indexes clamp to 0..=len and a reversed range is empty. Returns the byte range and the new position, pos + size (len for -1), which may be negative or past the end, as a Python Position can be. A bundle entry (File.py:78-81), parse_blob’s node area and string buffer, and the pure-Python reader’s TypelessData all read this way (plan section 3.6). Implemented by the scaffold.