Read the first 'size' bytes in packet and advance cursor past them.
(self, size)
| 60 | return self._data |
| 61 | |
| 62 | def read(self, size): |
| 63 | """Read the first 'size' bytes in packet and advance cursor past them.""" |
| 64 | result = self._data[self._position : (self._position + size)] |
| 65 | if len(result) != size: |
| 66 | error = ( |
| 67 | "Result length not requested length:\n" |
| 68 | f"Expected={size}. Actual={len(result)}. Position: {self._position}. Data Length: {len(self._data)}" |
| 69 | ) |
| 70 | if DEBUG: |
| 71 | print(error) |
| 72 | self.dump() |
| 73 | raise AssertionError(error) |
| 74 | self._position += size |
| 75 | return result |
| 76 | |
| 77 | def read_all(self): |
| 78 | """Read all remaining data in the packet. |
no test coverage detected