Binary Types
Strings and Bytes
Fixed, prefixed, and null-terminated fields
from typing import Annotated
from binal import BinaryModel, Fixed, NullTerminated, Prefixed, UInt16
class Record(BinaryModel, byte_order="big"):
name: Annotated[str, Fixed(32, encoding="utf-8")]
description: Annotated[str, Prefixed(UInt16, encoding="utf-8")]
identifier: Annotated[str, NullTerminated(encoding="ascii")] Bytes fields use the same markers: Fixed(n), Prefixed(UInt16), and Sized("length") for length-dependent fields.