Added ability to both read and write vectors*

This change affects the BinaryReader and BinaryWriter
Note that it only allows to write vectors of **TLObjects**,
not any other type
This commit is contained in:
Lonami
2016-09-26 16:10:07 +02:00
parent 36b8a9026f
commit ded655911e
2 changed files with 19 additions and 0 deletions

View File

@@ -128,6 +128,14 @@ class BinaryReader:
result.on_response(self)
return result
def tgread_vector(self):
"""Reads a vector (a list) of Telegram objects"""
if 0x1cb5c415 != self.read_int(signed=False):
raise ValueError('Invalid constructor code, vector was expected')
count = self.read_int()
return [self.tgread_object() for _ in range(count)]
# endregion
def close(self):