Exemple #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
Exemple #2
0
def skip_bytes(io: IO):
    io.read(unsigned_varint_serializer.load(io))
Exemple #3
0
def skip_fixed_64(io: IO):
    io.read(8)
Exemple #4
0
def skip_fixed_32(io: IO):
    io.read(4)
Exemple #5
0
def skip_varint(io: IO):
    while io.read(1)[0] & 0x80:
        pass
Exemple #6
0
 def load(self, io: IO) -> Any:
     return unpack('<d', io.read(8))[0]
Exemple #7
0
 def load(self, io: IO) -> Any:
     return unpack('<f', io.read(4))[0]
Exemple #8
0
 def load(self, io: IO) -> Any:
     length = unsigned_varint_serializer.load(io)
     return io.read(length)