Coverage for sbe2/schema/field.py: 100%
18 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-21 19:48 +0200
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-21 19:48 +0200
1from .common import FixedLengthElement, Presence
2from dataclasses import dataclass
3from functools import cached_property
4from typing import Any
7@dataclass
8class Field(FixedLengthElement):
9 """
10 Represents a field in the SBE schema.
11 """
13 id: int
14 type: FixedLengthElement
15 offset: int | None = None
16 alignment: int | None = None
17 presence: Presence = Presence.REQUIRED
18 value_ref: Any = None
19 constant_value: Any = None
20 since_version: int = 0
21 deprecated: int | None = None
23 @cached_property
24 def total_length(self) -> int:
25 """
26 Returns the total length of the field, which is the size of the type.
27 """
28 return self.type.total_length