def read_struct(inbuf, obj, decode_response=True):
    while True:
        f_type, fid = read_field_begin(inbuf)
        if f_type == TType.STOP:
            break

        if fid not in obj.thrift_spec:
            skip(inbuf, f_type)
            continue

        if len(obj.thrift_spec[fid]) == 3:
            sf_type, f_name, f_req = obj.thrift_spec[fid]
            f_container_spec = None
        else:
            sf_type, f_name, f_container_spec, f_req = obj.thrift_spec[fid]

        # it really should equal here. but since we already wasted
        # space storing the duplicate info, let's check it.
        if f_type != sf_type:
            skip(inbuf, f_type)
            continue

        setattr(obj, f_name,
                read_val(inbuf, f_type, f_container_spec, decode_response))
dataset/ETHPy150Open eleme/thriftpy/thriftpy/protocol/binary.py/read_struct/original