add from_bytes function

This commit is contained in:
Michael Becker 2024-08-27 00:33:49 -04:00
parent df5f06f695
commit 3fc96ae61e

View File

@ -44,6 +44,24 @@ class Guid:
result = int(parseWhat, 16)
parsePos += requiredLength
return (parsePos, result)
@staticmethod
def from_bytes(b : bytes):
guid = Guid()
guid.__a = (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0]
guid.__b = (b[5] << 8) | b[4]
guid.__c = ((b[7] << 8) | b[6])
guid.__d = b[8]
guid.__e = b[9]
guid.__f = b[10]
guid.__g = b[11]
guid.__h = b[12]
guid.__i = b[13]
guid.__j = b[14]
guid.__k = b[15]
return guid
@staticmethod
def __tryParseGuidWithDashes(guidString : str) -> UUIDParseResult: