I'm wondering what's the best way to binary encode a list of structs with ThriftPy. The only way I've found is to create another wrapper struct
and remove the binary prefix/suffix from the stream but this is very hacky and there should definitely be a better way.
foobar.thrift:
struct Object {
1: i32 num1 = 0,
2: i32 num2,
}
struct ListContainer {
1: list<Object> objects
}
app.py
foobar = thriftpy.load('foobar.thrift', module_name="foobar_thrift")
objects = [ ... list of Objects ... ]
thrift_obj = foobar.ListContainer(objects)
trans = TMemoryBuffer()
thrift_obj.write(TBinaryProtocol(trans))
encoded_list = bytes(trans.getvalue())[3:-1]