ByteEnum Primitive Examples

[1]:
from enum import IntEnum

from byteclasses.print import byteclass_info, byteclass_inspect
from byteclasses.types.primitives.byte_enum import ByteEnum
from byteclasses.types.primitives.integers import UInt8
[2]:
class TestEnum(IntEnum):
    """Test Enum class."""

    ONE = 0x1
    TWO = 0x2
    THREE = 0x3
[3]:
known = ByteEnum(TestEnum, UInt8, 3)
byteclass_info(known)
byteclass_inspect(known)
                   Byteclass Info                   
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Property                 ┃ Value                 ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━┩
│ type()                   │ ByteEnum              │
│ is_byteclass()           │ True                  │
│ is_collection_instance() │ False                 │
│ is_primitive_instance()  │ False                 │
│ mro                      │ ByteEnum -> object    │
│ len()                    │ 1                     │
│ str()                    │ THREE                 │
│ repr()                   │ <TestEnum.THREE: 0x3> │
│ .data                    │ b'\x03'               │
└──────────────────────────┴───────────────────────┘
╭────────────────── Byteclass Inspect ───────────────────╮
│      00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f   │
│ ----------------------------------------------------   │
│ 0x0 |03                                                │
╰────────────────────────────────────────────────────────╯
 Legend  
┏━━━━━━━┓
┃ Value ┃
┡━━━━━━━┩
│ THREE │
└───────┘
[4]:
unknown = ByteEnum(TestEnum, UInt8, 4)
byteclass_info(unknown)
byteclass_inspect(unknown)
                    Byteclass Info                    
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Property                 ┃ Value                   ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ type()                   │ ByteEnum                │
│ is_byteclass()           │ True                    │
│ is_collection_instance() │ False                   │
│ is_primitive_instance()  │ False                   │
│ mro                      │ ByteEnum -> object      │
│ len()                    │ 1                       │
│ str()                    │ UNKNOWN                 │
│ repr()                   │ <TestEnum.UNKNOWN: 0x4> │
│ .data                    │ b'\x04'                 │
└──────────────────────────┴─────────────────────────┘
╭────────────────── Byteclass Inspect ───────────────────╮
│      00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f   │
│ ----------------------------------------------------   │
│ 0x0 |04                                                │
╰────────────────────────────────────────────────────────╯
  Legend   
┏━━━━━━━━━┓
┃ Value   ┃
┡━━━━━━━━━┩
│ UNKNOWN │
└─────────┘