MCPcopy Create free account
hub / github.com/apache/fory / OneByteWriteStream

Class OneByteWriteStream

python/pyfory/tests/test_stream.py:75–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73
74
75class 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
90class CountingWriteStream:

Calls

no outgoing calls