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

Class PartialWriteStream

python/pyfory/tests/test_buffer.py:68–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66
67
68class PartialWriteStream:
69 def __init__(self):
70 self._data = bytearray()
71
72 def write(self, payload):
73 if not payload:
74 return 0
75 view = memoryview(payload).cast("B")
76 wrote = min(2, len(view))
77 self._data.extend(view[:wrote])
78 return wrote
79
80 def to_bytes(self):
81 return bytes(self._data)
82
83
84def test_buffer():

Calls

no outgoing calls