blob: 8ec703db7d32bd983f0ed4e13d2fc38caaaef0c3 [file] [log] [blame]
David Reiss6acc2692010-02-26 00:56:02 +00001from protocol import TBinaryProtocol
2from transport import TTransport
3
4def serialize(thrift_object, protocol_factory = TBinaryProtocol.TBinaryProtocolFactory()):
5 transport = TTransport.TMemoryBuffer()
6 protocol = protocol_factory.getProtocol(transport)
7 thrift_object.write(protocol)
8 return transport.getvalue()
9
10def deserialize(base, buf, protocol_factory = TBinaryProtocol.TBinaryProtocolFactory()):
11 transport = TTransport.TMemoryBuffer(buf)
12 protocol = protocol_factory.getProtocol(transport)
13 base.read(protocol)
14 return base
15