(fo: tp.IO[bytes], size: int)
| 29 | |
| 30 | |
| 31 | def _read_exactly(fo: tp.IO[bytes], size: int) -> bytes: |
| 32 | buf = b"" |
| 33 | while len(buf) < size: |
| 34 | new_buf = fo.read(size) |
| 35 | if not new_buf: |
| 36 | raise EOFError("Impossible to read enough data from the stream, " |
| 37 | f"{size} bytes remaining.") |
| 38 | buf += new_buf |
| 39 | size -= len(new_buf) |
| 40 | return buf |
| 41 | |
| 42 | |
| 43 | def read_ecdc_header(fo: tp.IO[bytes]): |