| 965 | |
| 966 | |
| 967 | class BytesBufferObject(BufferObject): |
| 968 | __slots__ = ("binary",) |
| 969 | |
| 970 | def __init__(self, binary: bytes): |
| 971 | self.binary = binary |
| 972 | |
| 973 | def total_bytes(self) -> int: |
| 974 | return len(self.binary) |
| 975 | |
| 976 | def write_to(self, stream): |
| 977 | if hasattr(stream, "write_bytes"): |
| 978 | stream.write_bytes(self.binary) |
| 979 | else: |
| 980 | stream.write(self.binary) |
| 981 | |
| 982 | def getbuffer(self) -> memoryview: |
| 983 | return memoryview(self.binary) |
| 984 | |
| 985 | |
| 986 | class PickleBufferSerializer(Serializer): |