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

Class FinalModelBalance

projects/Python/proto/proto.py:1474–1581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1472
1473
1474class FinalModelBalance(fbe.FinalModel):
1475 __slots__ = "_currency", "_amount",
1476
1477 def __init__(self, buffer, offset):
1478 super().__init__(buffer, offset)
1479 self._currency = fbe.FinalModelString(buffer, 0)
1480 self._amount = fbe.FinalModelDouble(buffer, 0)
1481
1482 @property
1483 def currency(self):
1484 return self._currency
1485
1486 @property
1487 def amount(self):
1488 return self._amount
1489
1490 # Get the allocation size
1491 def fbe_allocation_size(self, fbe_value):
1492 fbe_result = 0 \
1493 + self.currency.fbe_allocation_size(fbe_value.currency) \
1494 + self.amount.fbe_allocation_size(fbe_value.amount) \
1495
1496 return fbe_result
1497
1498 # Get the final type
1499 @property
1500 def fbe_type(self):
1501 return self.TYPE
1502
1503 TYPE = 2
1504
1505 # Check if the struct value is valid
1506 def verify(self):
1507 self._buffer.shift(self.fbe_offset)
1508 fbe_result = self.verify_fields()
1509 self._buffer.unshift(self.fbe_offset)
1510 return fbe_result
1511
1512 # Check if the struct fields are valid
1513 def verify_fields(self):
1514 fbe_current_offset = 0
1515
1516 self.currency.fbe_offset = fbe_current_offset
1517 fbe_field_size = self.currency.verify()
1518 if fbe_field_size == sys.maxsize:
1519 return sys.maxsize
1520 fbe_current_offset += fbe_field_size
1521
1522 self.amount.fbe_offset = fbe_current_offset
1523 fbe_field_size = self.amount.verify()
1524 if fbe_field_size == sys.maxsize:
1525 return sys.maxsize
1526 fbe_current_offset += fbe_field_size
1527
1528 return fbe_current_offset
1529
1530 # Get the struct value
1531 def get(self, fbe_value=None):

Callers 3

__init__Method · 0.70
__init__Method · 0.70
__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected