Example #1
0
def read_varint(io: IO) -> types.uint:
    """
    Read unsigned `VarInt` from a file-like object.
    """
    value = 0
    for shift in count(0, 7):
        byte, = io.read(1)
        value |= (byte & 0x7F) << shift
        if not byte & 0x80:
            return value
Example #2
0
def skip_bytes(io: IO):
    io.read(unsigned_varint_serializer.load(io))
Example #3
0
def skip_fixed_64(io: IO):
    io.read(8)
Example #4
0
def skip_fixed_32(io: IO):
    io.read(4)
Example #5
0
def skip_varint(io: IO):
    while io.read(1)[0] & 0x80:
        pass
Example #6
0
 def load(self, io: IO) -> Any:
     return unpack('<d', io.read(8))[0]
Example #7
0
 def load(self, io: IO) -> Any:
     return unpack('<f', io.read(4))[0]
Example #8
0
 def load(self, io: IO) -> Any:
     length = unsigned_varint_serializer.load(io)
     return io.read(length)