23 lines
565 B
Python
23 lines
565 B
Python
from typing import Any, Union
|
|
|
|
from .valuetype import ValueType
|
|
|
|
ValueData = Union[None, bytes]
|
|
|
|
|
|
class Value:
|
|
__slots__ = ('value_type', 'data', )
|
|
|
|
value_type: ValueType
|
|
data: ValueData
|
|
|
|
def __init__(self, value_type: ValueType, data: ValueData) -> None:
|
|
self.value_type = value_type
|
|
self.data = data
|
|
|
|
def __eq__(self, other: Any) -> bool:
|
|
return self.value_type is other.value_type and self.data == other.data
|
|
|
|
def __repr__(self) -> str:
|
|
return f'Value(valuetype.{self.value_type.name}, {repr(self.data)})'
|