pystructtype.structtypes
structtypes: Type system and helpers for pystructtype.
Attributes
Generic Data Type for TypeMeta Contents |
|
1 Byte Signed int Type |
|
1 Byte Unsigned int Type |
|
2 Byte Signed int Type |
|
2 Byte Unsigned int Type |
|
4 Byte Signed int Type |
|
4 Byte Unsigned int Type |
|
8 Byte Signed int Type |
|
8 Byte Unsigned int Type |
|
1 Byte bool Type |
|
4 Byte float Type |
|
8 Byte double Type |
|
1 Byte char Type |
|
1 Byte char[] Type |
Classes
Class used to define Annotated Type Metadata for |
|
Class used to define Annotated Type Metadata |
|
Contains all relevant type information for |
Functions
|
Iterate through the given StructDataclass attributes type hints and yield |
|
Find the base type from an Annotated type, or return it unchanged if not Annotated. |
Module Contents
- class pystructtype.structtypes.TypeMeta[T](size: int = 1, chunk_size: int = 1, default: T | None = None)[source]
Class used to define Annotated Type Metadata for size and default values
- class pystructtype.structtypes.TypeInfo[source]
Class used to define Annotated Type Metadata for format and byte size
- class pystructtype.structtypes.TypeIterator[source]
Contains all relevant type information for an object in a StructDataclass.
Used as a container when iterating through StructDataclass attributes
- property size: int[source]
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.
- Returns:
integer containing the size of the type
- property chunk_size: int[source]
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.
- Returns:
integer containing the chunk size of the type
- pystructtype.structtypes.iterate_types(cls: type) collections.abc.Generator[TypeIterator][source]
Iterate through the given StructDataclass attributes type hints and yield a TypeIterator for each one.
- Parameters:
cls – A StructDataclass class object (not an instantiated object)
- Returns:
Yield a TypeIterator object
- Raises:
TypeError – If cls is not a type