pystructtype.bitstype ===================== .. py:module:: pystructtype.bitstype .. autoapi-nested-parse:: BitsType: Base class for bitfield structs. Classes ------- .. autoapisummary:: pystructtype.bitstype.BitsType Module Contents --------------- .. py:class:: BitsType Bases: :py:obj:`pystructtype.structdataclass.StructDataclass` Base class for bitfield structs. Subclasses must define __bits_type__ and __bits_definition__. .. py:attribute:: __bits_type__ :type: ClassVar[type] .. py:attribute:: __bits_definition__ :type: ClassVar[dict[str, int | list[int]] | collections.abc.Mapping[str, int | list[int]]] .. py:attribute:: _raw :type: int .. py:attribute:: _meta :type: dict[str, int | list[int]] .. py:method:: __init_subclass__(**kwargs: object) -> None :classmethod: Initialize subclass by setting up bitfield attributes and type annotations. Ensures __bits_type__ and __bits_definition__ are present, wraps definition in MappingProxyType, and sets up class-level fields and annotations for each bitfield. .. py:method:: __post_init__() -> None Post-initialization to set up the _meta attribute from the class definition. .. py:method:: _decode(data: list[int]) -> None Decode the bitfield from a list of integers, updating the boolean attributes according to the bit positions defined in _meta. .. py:method:: _encode() -> list[int] Encode the boolean attributes into a list of integers representing the bitfield. Updates _raw and returns the encoded list for further processing.