Structs
packtype.utils.struct
get_field_type(field)
Get the type name of a field in a Packtype struct.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field
|
Base
|
The field to inspect |
required |
Returns:
Type | Description |
---|---|
str | None
|
The type name of the field if it is not a simple field, else None |
get_fields_lsb_asc(struct)
Get the fields of a Packtype struct in LSB-first order.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
struct
|
Struct | type[Struct]
|
The Packtype struct to inspect |
required |
Returns:
Type | Description |
---|---|
list[tuple[int, int, tuple[str, Base]]]
|
List of tuples of LSB, MSB, and inner tuple of field name and type |
get_fields_msb_desc(struct)
Get the fields of a Packtype struct in MSB-first order.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
struct
|
Struct | type[Struct]
|
The Packtype struct to inspect |
required |
Returns:
Type | Description |
---|---|
list[tuple[int, int, tuple[str, Base]]]
|
List of tuples of LSB, MSB, and inner tuple of field name and type |
is_simple_field(field)
Check if a field in a Packtype struct is a simple scalar field and does not refer to another existing type
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field
|
Base
|
The field to check |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the field is a simple field, False otherwise |
is_struct(ptype)
Check if a Packtype definition is a struct.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ptype
|
type[Base] | Base
|
The Packtype definition to check |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the definition is a struct, False otherwise |