Implement network-encoded UUID type.

This commit is contained in:
joo 2015-09-05 08:32:27 +01:00
parent fe66e09dc4
commit 6aea7b36c1

View File

@ -3,6 +3,7 @@ Each type has a method which is used to read and write it.
These definitions and methods are used by the packet definitions
"""
import struct
import uuid
class Type(object):
@ -201,3 +202,8 @@ class String(Type):
value = value.encode('utf-8')
VarInt.send(len(value), socket)
socket.send(value)
class UUID(Type):
@staticmethod
def read(file_object):
return str(uuid.UUID(bytes=file_object.read(16)))