mirror of
https://github.com/kokarare1212/librespot-python.git
synced 2024-10-04 18:16:54 +02:00
25 lines
494 B
Python
25 lines
494 B
Python
|
import struct
|
||
|
|
||
|
|
||
|
class BytesOutputStream:
|
||
|
buffer: bytes
|
||
|
|
||
|
def __init__(self):
|
||
|
self.buffer = b""
|
||
|
|
||
|
def write(self, data: bytes):
|
||
|
self.buffer += data
|
||
|
return len(data)
|
||
|
|
||
|
def write_byte(self, data: int):
|
||
|
self.buffer += bytes([data])
|
||
|
return 1
|
||
|
|
||
|
def write_int(self, data: int):
|
||
|
self.buffer += struct.pack(">i", data)
|
||
|
return 4
|
||
|
|
||
|
def write_short(self, data: int):
|
||
|
self.buffer += struct.pack(">h", data)
|
||
|
return 2
|