This is needed for flag fields where users want to pack more information into the most significant bits. For instance, consider the following flag enum:
class DataRate(IntFlagProperties, s('label'), s('slug', case_fold=True)):
DAILY = 2**1, 'Daily', 'daily'
HOURLY = 2**2, 'Hourly', 'hourly'
HIGH_RATE = 2**3, 'High Rate', 'high'
# bits 4-16 are reserved for daily data rate in seconds
# bits 17-27 are reserved for hourly data rate in seconds
# bits 28-32 are reserved for high rate data rate in seconds
This flag qualifies rates into categories, but for each category a higher resolution period in seconds can be packed into the msbs. EnumField would only see the three flags and use a SmallPositiveInteger for this field. The user should be able to override this behavior with something like EnumField(DataRate, bit_length=32) to force EnumField to pick PositiveIntegerField instead.
This is needed for flag fields where users want to pack more information into the most significant bits. For instance, consider the following flag enum:
This flag qualifies rates into categories, but for each category a higher resolution period in seconds can be packed into the msbs. EnumField would only see the three flags and use a SmallPositiveInteger for this field. The user should be able to override this behavior with something like EnumField(DataRate, bit_length=32) to force EnumField to pick PositiveIntegerField instead.