Reader that yields `size` zero bytes without holding them.
| 868 | |
| 869 | |
| 870 | class _ZeroSource: |
| 871 | """Reader that yields `size` zero bytes without holding them.""" |
| 872 | |
| 873 | def __init__(self, size: int): |
| 874 | self._remaining = size |
| 875 | |
| 876 | def read(self, size=-1): |
| 877 | if size is None or size < 0: |
| 878 | size = self._remaining |
| 879 | count = min(size, self._remaining) |
| 880 | self._remaining -= count |
| 881 | return bytes(count) |
| 882 | |
| 883 | |
| 884 | class _CountingSink: |
no outgoing calls