| 73 | |
| 74 | |
| 75 | class OneByteWriteStream: |
| 76 | def __init__(self): |
| 77 | self._data = bytearray() |
| 78 | |
| 79 | def write(self, payload): |
| 80 | if not payload: |
| 81 | return 0 |
| 82 | view = memoryview(payload).cast("B") |
| 83 | self._data.append(view[0]) |
| 84 | return 1 |
| 85 | |
| 86 | def to_bytes(self): |
| 87 | return bytes(self._data) |
| 88 | |
| 89 | |
| 90 | class CountingWriteStream: |
no outgoing calls