Abstract base classes#
Struct#
- class caterpillar.abc._SupportsPack(*args, **kwargs)[source]#
An abstract base class for objects that support packing data into a binary stream.
- class caterpillar.abc._SupportsUnpack(*args, **kwargs)[source]#
An abstract base class for objects that support unpacking data from a binary stream.
- class caterpillar.abc._SupportsSize(*args, **kwargs)[source]#
An abstract base class for objects that support determining the size of packed data.
Context#
Other base classes#
Standard interface#
- abc.STRUCT_FIELD = '__struct__'#
- caterpillar.abc.hasstruct(obj: Any) bool [source]#
Check if the given object has a structure attribute.
- Parameters:
obj – The object to check.
- Returns:
True if the object has a structure attribute, else False.
- caterpillar.abc.getstruct(obj: Any, /, __default: Any = None) _StructLike | None [source]#
Get the structure attribute of the given object.
- Parameters:
obj – The object to get the structure attribute from.
- Returns:
The structure attribute of the object.
- caterpillar.abc.typeof(struct: _StructLike | _ContainsStruct) object [source]#