Beispiel #1
0
    def skip(self, ttype):
        if ttype == TType.STOP:
            return

        elif ttype == TType.BOOL:
            yield from self._read_bool()

        elif ttype == TType.BYTE:
            yield from self._read_byte()

        elif ttype in (TType.I16, TType.I32, TType.I64):
            from_zig_zag((yield from read_varint(self.trans)))

        elif ttype == TType.DOUBLE:
            yield from self._read_double()

        elif ttype == TType.BINARY:
            yield from self._read_binary()

        elif ttype == TType.STRING:
            yield from self._read_string()

        elif ttype == TType.STRUCT:
            self._read_struct_begin()
            while True:
                name, ttype, id = yield from self._read_field_begin()
                if ttype == TType.STOP:
                    break
                yield from self.skip(ttype)
                self._read_field_end()
            self._read_struct_end()

        elif ttype == TType.MAP:
            ktype, vtype, size = yield from self._read_map_begin()
            for i in range(size):
                yield from self.skip(ktype)
                yield from self.skip(vtype)
            self._read_collection_end()

        elif ttype == TType.SET:
            etype, size = yield from self._read_collection_begin()
            for i in range(size):
                yield from self.skip(etype)
            self._read_collection_end()

        elif ttype == TType.LIST:
            etype, size = yield from self._read_collection_begin()
            for i in range(size):
                yield from self.skip(etype)
            self._read_collection_end()
Beispiel #2
0
    def _read_field_begin(self):
        type = yield from self._read_ubyte()
        if type & 0x0f == TType.STOP:
            return None, 0, 0

        delta = type >> 4
        if delta == 0:
            fid = from_zig_zag((yield from read_varint(self.trans)))
        else:
            fid = self._last_fid + delta
        self._last_fid = fid

        type = type & 0x0f
        if type == CompactType.TRUE:
            self._bool_value = True
        elif type == CompactType.FALSE:
            self._bool_value = False

        return None, self._get_ttype(type), fid
Beispiel #3
0
 def _read_int(self):
     return from_zig_zag((yield from read_varint(self.trans)))
Beispiel #4
0
 async def _read_int(self):
     return from_zig_zag(await read_varint(self.trans))