pak.types.misc

Miscellaneous Types.

class EmptyType

Bases: Type

A Type of no value.

It always unpacks to None and always packs to b"". It is useful in certain cases when you would want to “disable” a packet field, for instance.

None is a typelike value that translates to EmptyType.

class Padding

Bases: Type

A single byte of padding.

This Type will marshal one byte to None, and any value to b"\x00".

It is also special-cased in Array for padding of larger length.

class RawByte

Bases: Type

A single byte of data.

The main reason this exists is to be used along with Array, for which this Type is special-cased to produce a bytearray value.

class StructType

Bases: Type

A wrapper over struct.pack() and struct.unpack().

fmt

The format string for the structure, not including the endianness prefix.

Type:

str

endian

The endianness prefix used in struct.

By default little-endian.

Type:

str

classmethod big_endian()

Gets a big-endian version of the StructType.

Returns:

If the StructType is already big-endian, then it is simply returned.

Otherwise, a subclass with the proper endianness is returned.

Return type:

subclass of StructType

endian = '<'
fmt = None
classmethod little_endian()

Gets a little-endian version of the StructType.

Returns:

If the StructType is already little-endian, then it is simply returned.

Otherwise, a subclass with the proper endianness is returned.

Return type:

subclass of StructType

classmethod native_endian()

Gets a native-endian version of the StructType.

Returns:

If the StructType is already native-endian, then it is simply returned.

Otherwise, a subclass with the proper endianness is returned.

Return type:

subclass of StructType