Layout
source: bluebase/core/layout.py
- dataclassclass LayoutField(name: str, format: str)[source]
Bases:
objectA field in a byte-level layout.
- Variables:
name (str) – the name of the field
format (str) – the format of the field used by the
structmodule, excluding the endian prefixsize (int) – the size of the field, automatically calculated from its format
- class LayoutMixin(buffer: bytearray)[source]
Bases:
ABCAn abstract base class for defining byte-level layouts.
It holds a buffer internally and manages its layout according to the configured
fields.- Variables:
buffer (bytearray) – the underlying buffer organized according to the layout
- Raises:
TypeError – if
fieldsis not properly defined
- ENDIAN: ClassVar[str] = '<'
The endian format used by the
structmodule.
- lookup: ClassVar[dict[str, tuple[int, LayoutField]]]
A mapping from each field name to its offset and field, generated automatically.
- fields: ClassVar[tuple[LayoutField, ...]]
The fields that define the layout.
- get_format(field: LayoutField) str[source]
Return the format of a field, including the endian prefix.