pystructtype.structtypes ======================== .. py:module:: pystructtype.structtypes .. autoapi-nested-parse:: structtypes: Type system and helpers for pystructtype. Attributes ---------- .. autoapisummary:: pystructtype.structtypes.T pystructtype.structtypes.int8_t pystructtype.structtypes.uint8_t pystructtype.structtypes.int16_t pystructtype.structtypes.uint16_t pystructtype.structtypes.int32_t pystructtype.structtypes.uint32_t pystructtype.structtypes.int64_t pystructtype.structtypes.uint64_t pystructtype.structtypes.bool_t pystructtype.structtypes.float_t pystructtype.structtypes.double_t pystructtype.structtypes.char_t pystructtype.structtypes.string_t Classes ------- .. autoapisummary:: pystructtype.structtypes.TypeMeta pystructtype.structtypes.TypeInfo pystructtype.structtypes.TypeIterator Functions --------- .. autoapisummary:: pystructtype.structtypes.iterate_types pystructtype.structtypes.type_from_annotation Module Contents --------------- .. py:data:: T Generic Data Type for TypeMeta Contents .. py:class:: TypeMeta[T](size: int = 1, chunk_size: int = 1, default: T | None = None) Class used to define Annotated Type Metadata for size and default values .. py:attribute:: size :value: 1 .. py:attribute:: chunk_size :value: 1 .. py:attribute:: default :value: None .. py:method:: __hash__() -> int .. py:method:: __eq__(other: Any) -> bool .. py:class:: TypeInfo Class used to define Annotated Type Metadata for format and byte size .. py:attribute:: format :type: str .. py:attribute:: byte_size :type: int .. py:data:: int8_t 1 Byte Signed int Type .. py:data:: uint8_t 1 Byte Unsigned int Type .. py:data:: int16_t 2 Byte Signed int Type .. py:data:: uint16_t 2 Byte Unsigned int Type .. py:data:: int32_t 4 Byte Signed int Type .. py:data:: uint32_t 4 Byte Unsigned int Type .. py:data:: int64_t 8 Byte Signed int Type .. py:data:: uint64_t 8 Byte Unsigned int Type .. py:data:: bool_t 1 Byte bool Type .. py:data:: float_t 4 Byte float Type .. py:data:: double_t 8 Byte double Type .. py:data:: char_t 1 Byte char Type .. py:data:: string_t 1 Byte char[] Type .. py:class:: TypeIterator Contains all relevant type information for an object in a StructDataclass. Used as a container when iterating through StructDataclass attributes .. py:attribute:: key :type: str .. py:attribute:: base_type :type: type .. py:attribute:: type_info :type: TypeInfo | None .. py:attribute:: type_meta :type: TypeMeta[Any] | None .. py:attribute:: is_list :type: bool .. py:attribute:: is_pystructtype :type: bool .. py:property:: size :type: int Return the size of the type. If this is not a list, this will default to 1, else this will return the size defined in the `type_meta` object if it exists. :return: integer containing the size of the type .. py:property:: chunk_size :type: int Return the chunk size of the type. Typically, this is used for char[]/string types as these are defined in chunks rather than in a size of individual values. This defaults to 1, else this will return the size defined in the `type_meta` object if it exists. :return: integer containing the chunk size of the type .. py:function:: iterate_types(cls: type) -> collections.abc.Generator[TypeIterator] Iterate through the given StructDataclass attributes type hints and yield a TypeIterator for each one. :param cls: A StructDataclass class object (not an instantiated object) :return: Yield a TypeIterator object :raises TypeError: If cls is not a type .. py:function:: type_from_annotation(_type: Any) -> type[Any] Find the base type from an Annotated type, or return it unchanged if not Annotated. :param _type: Type or Annotated Type to check :return: Base type if Annotated, or the original passed in type otherwise