Field for UUID storage, wrapping Python's uuid.UUID type. The internal storage format of this field is ``uuid.UUID`` from the Python standard library. There are three formats (``uuid_fmt``) for this field type: * ``FORMAT_BE`` (default): the UUID is six fields in big-endian byte o
| 3764 | |
| 3765 | |
| 3766 | class UUIDField(Field[UUID, bytes]): |
| 3767 | """Field for UUID storage, wrapping Python's uuid.UUID type. |
| 3768 | |
| 3769 | The internal storage format of this field is ``uuid.UUID`` from the Python |
| 3770 | standard library. |
| 3771 | |
| 3772 | There are three formats (``uuid_fmt``) for this field type: |
| 3773 | |
| 3774 | * ``FORMAT_BE`` (default): the UUID is six fields in big-endian byte order, |
| 3775 | per RFC 4122. |
| 3776 | |
| 3777 | This format is used by DHCPv6 (RFC 6355) and most network protocols. |
| 3778 | |
| 3779 | * ``FORMAT_LE``: the UUID is six fields, with ``time_low``, ``time_mid`` |
| 3780 | and ``time_high_version`` in little-endian byte order. This *doesn't* |
| 3781 | change the arrangement of the fields from RFC 4122. |
| 3782 | |
| 3783 | This format is used by Microsoft's COM/OLE libraries. |
| 3784 | |
| 3785 | * ``FORMAT_REV``: the UUID is a single 128-bit integer in little-endian |
| 3786 | byte order. This *changes the arrangement* of the fields. |
| 3787 | |
| 3788 | This format is used by Bluetooth Low Energy. |
| 3789 | |
| 3790 | Note: You should use the constants here. |
| 3791 | |
| 3792 | The "human encoding" of this field supports a number of different input |
| 3793 | formats, and wraps Python's ``uuid.UUID`` library appropriately: |
| 3794 | |
| 3795 | * Given a bytearray, bytes or str of 16 bytes, this class decodes UUIDs in |
| 3796 | wire format. |
| 3797 | |
| 3798 | * Given a bytearray, bytes or str of other lengths, this delegates to |
| 3799 | ``uuid.UUID`` the Python standard library. This supports a number of |
| 3800 | different encoding options -- see the Python standard library |
| 3801 | documentation for more details. |
| 3802 | |
| 3803 | * Given an int or long, presumed to be a 128-bit integer to pass to |
| 3804 | ``uuid.UUID``. |
| 3805 | |
| 3806 | * Given a tuple: |
| 3807 | |
| 3808 | * Tuples of 11 integers are treated as having the last 6 integers forming |
| 3809 | the ``node`` field, and are merged before being passed as a tuple of 6 |
| 3810 | integers to ``uuid.UUID``. |
| 3811 | |
| 3812 | * Otherwise, the tuple is passed as the ``fields`` parameter to |
| 3813 | ``uuid.UUID`` directly without modification. |
| 3814 | |
| 3815 | ``uuid.UUID`` expects a tuple of 6 integers. |
| 3816 | |
| 3817 | Other types (such as ``uuid.UUID``) are passed through. |
| 3818 | """ |
| 3819 | |
| 3820 | __slots__ = ["uuid_fmt"] |
| 3821 | |
| 3822 | FORMAT_BE = 0 |
| 3823 | FORMAT_LE = 1 |
no outgoing calls
no test coverage detected