MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / StructBytes

Class StructBytes

projects/Python/proto/test.py:8475–8577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8473
8474@functools.total_ordering
8475class StructBytes(object):
8476 __slots__ = "f1", "f2", "f3",
8477
8478 def __init__(self, f1=None, f2=None, f3=None):
8479 if f1 is None:
8480 f1 = bytearray()
8481 self.f1 = f1
8482 self.f2 = f2
8483 self.f3 = f3
8484
8485 # Struct shallow copy
8486 def copy(self, other):
8487 self.f1 = other.f1
8488 self.f2 = other.f2
8489 self.f3 = other.f3
8490 return self
8491
8492 # Struct deep clone
8493 def clone(self):
8494 # Serialize the struct to the FBE stream
8495 writer = StructBytesModel(fbe.WriteBuffer())
8496 writer.serialize(self)
8497
8498 # Deserialize the struct from the FBE stream
8499 reader = StructBytesModel(fbe.ReadBuffer())
8500 reader.attach_buffer(writer.buffer)
8501 return reader.deserialize()[0]
8502
8503 def __eq__(self, other):
8504 if not isinstance(self, other.__class__):
8505 return NotImplemented
8506 return True
8507
8508 def __lt__(self, other):
8509 if not isinstance(self, other.__class__):
8510 return NotImplemented
8511 return False
8512
8513 @property
8514 def __key__(self):
8515 return ()
8516
8517 def __hash__(self):
8518 return hash(self.__key__)
8519
8520 def __format__(self, format_spec):
8521 return self.__str__()
8522
8523 def __str__(self):
8524 sb = list()
8525 sb.append("StructBytes(")
8526 sb.append("f1=")
8527 if self.f1 is not None:
8528 sb.append("bytes[" + str(len(self.f1)) + "]")
8529 else:
8530 sb.append("null")
8531 sb.append(",f2=")
8532 if self.f2 is not None:

Callers 5

__from_json__Method · 0.70
getMethod · 0.70
deserializeMethod · 0.70
getMethod · 0.70
deserializeMethod · 0.70

Calls

no outgoing calls

Tested by 5

__from_json__Method · 0.56
getMethod · 0.56
deserializeMethod · 0.56
getMethod · 0.56
deserializeMethod · 0.56