netbits.buffer.Buffer¶
- class netbits.buffer.Buffer(buffer: bytearray)[source]¶
Bases:
objectA class to handle reading and writing of binary data with support for integers and strings.
- Parameters:
buffer (bytearray) – A bytearray to store the binary data.
- __init__(buffer: bytearray)[source]¶
Initialize the Buffer instance.
- Parameters:
buffer (bytearray) – A bytearray to store the binary data.
Methods
__init__(buffer)Initialize the Buffer instance.
read_int()Read an integer from the buffer.
Read a string from the buffer.
write_int(value)Write an integer to the buffer.
write_string(value)Write a string to the buffer.
- read_int() int[source]¶
Read an integer from the buffer.
- Returns:
The integer value read from the buffer.
- Return type:
int
- read_string() str[source]¶
Read a string from the buffer.
- Returns:
The string value read from the buffer.
- Return type:
str