4.10. Types (Extended Syntax)#

caterpillar.types.uint8_t#

Unsigned 8-bit integer field.

Added in version 2.8.0.

alias of Annotated[int, <int8>]

caterpillar.types.uint16_t#

Unsigned 16-bit integer field.

Added in version 2.8.0.

alias of Annotated[int, <int16>]

caterpillar.types.uint24_t#

Unsigned 24-bit integer field.

Added in version 2.8.0.

alias of Annotated[int, <uint24>]

caterpillar.types.uint32_t#

Unsigned 32-bit integer field.

Added in version 2.8.0.

alias of Annotated[int, <int32>]

caterpillar.types.uint64_t#

Unsigned 64-bit integer field.

Added in version 2.8.0.

alias of Annotated[int, <int64>]

caterpillar.types.int8_t#

Signed 8-bit integer field.

Usage Example:
>>> @bitfield
... class Packet:
...     value: int8_t

Added in version 2.8.0.

alias of Annotated[int, <int8>]

caterpillar.types.int16_t#

Signed 16-bit integer field.

Added in version 2.8.0.

alias of Annotated[int, <int16>]

caterpillar.types.int24_t#

Signed 24-bit integer field.

Added in version 2.8.0.

alias of Annotated[int, <int24>]

caterpillar.types.int32_t#

Signed 32-bit integer field.

Added in version 2.8.0.

alias of Annotated[int, <int32>]

caterpillar.types.int64_t#

Signed 64-bit integer field.

Added in version 2.8.0.

alias of Annotated[int, <int64>]

caterpillar.types.float16_t#

16-bit floating point field.

Added in version 2.8.0.

alias of Annotated[float, <float16>]

caterpillar.types.float32_t#

32-bit floating point field.

Added in version 2.8.0.

alias of Annotated[float, <float32>]

caterpillar.types.float64_t#

64-bit floating point field.

Added in version 2.8.0.

alias of Annotated[float, <float64>]

caterpillar.types.double_t#

Alias for 64-bit floating point field.

Added in version 2.8.0.

alias of Annotated[float, <float64>]

caterpillar.types.size_t#

Unsigned platform-sized integer field.

Added in version 2.8.0.

alias of Annotated[int, <int64>]

caterpillar.types.ssize_t#

Signed platform-sized integer field.

Added in version 2.8.0.

alias of Annotated[int, <int64>]

caterpillar.types.uuid_t#

UUID field mapped to uuid.UUID.

Usage Example:
>>> identifier: uuid_t

Added in version 2.8.0.

alias of Annotated[UUID, <Uuid>]

caterpillar.types.pass_t#

Placeholder field that consumes no data and performs no action.

Added in version 2.8.0.

alias of Annotated[None, <Pass>]

caterpillar.types.cstr_t#

C-style null-terminated string field with a dynamic size.

Usage Example:
>>> name: cstr_t

Added in version 2.8.0.

alias of Annotated[str, <CString>]

caterpillar.types.MAC_t#

MAC address field represented as 6 raw bytes.

Added in version 2.8.0.

alias of Annotated[bytes, <MACAddress>]

caterpillar.types.ipv4_t#

IPv4 address field mapped to ipaddress.IPv4Address.

Added in version 2.8.0.

alias of Annotated[IPv4Address, <IPv4Address>]

caterpillar.types.ipv6_t#

IPv6 address field mapped to ipaddress.IPv6Address.

Added in version 2.8.0.

alias of Annotated[IPv4Address, <IPv6Address>]

caterpillar.types.vint_t#

Variable-length integer field using a compact encoding.

Added in version 2.8.0.

alias of Annotated[int, <VarInt>]

caterpillar.types.int1_t#

1-bit integer field.

Represents a single signed bit typically used in bitfield definitions.

Usage Example:
>>> @bitfield
... class Flags:
...     enabled: int1_t

Note

Only usable in bitfields.

Added in version 2.8.0.

alias of Annotated[int, 1]

caterpillar.types.int2_t#

2-bit integer field for compact bitfield storage.

Note

Only usable in bitfields.

Added in version 2.8.0.

alias of Annotated[int, 2]

caterpillar.types.int3_t#

3-bit integer field for compact bitfield storage.

Note

Only usable in bitfields.

Added in version 2.8.0.

alias of Annotated[int, 3]

caterpillar.types.int4_t#

4-bit integer field for compact bitfield storage.

Note

Only usable in bitfields.

Added in version 2.8.0.

alias of Annotated[int, 4]

caterpillar.types.int5_t#

5-bit integer field for compact bitfield storage.

Note

Only usable in bitfields.

Added in version 2.8.0.

alias of Annotated[int, 5]

caterpillar.types.int6_t#

6-bit integer field for compact bitfield storage.

Note

Only usable in bitfields.

Added in version 2.8.0.

alias of Annotated[int, 6]

caterpillar.types.int7_t#

7-bit integer field for compact bitfield storage.

Note

Only usable in bitfields.

Added in version 2.8.0.

alias of Annotated[int, 7]

caterpillar.types.void_ptr_t#

Pointer-sized integer field representing a memory address.

Added in version 2.8.0.

alias of Annotated[int, <int64>]

caterpillar.types.balign_t#

Bit-alignment field used to align to the next byte boundary in bitfields.

This type MUST be used together with Invisible() to remove it from the constructor:

@bitfield
class Format:
    value: int2_t
    _    : balign_t     = Invisible() # not visible to the type checker

Note

Only usable in bitfields.

Added in version 2.8.0.

alias of Annotated[None, 0]

caterpillar.types.timestamp_t#

Timestamp field mapped to datetime.datetime.

Added in version 2.8.0.

alias of Annotated[datetime, <Timestamp>]