Coverage for sbe2/schema/ref.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2025-06-21 19:48 +0200

1from .common import FixedLengthElement 

2from dataclasses import dataclass 

3from functools import cached_property 

4 

5@dataclass 

6class Ref(FixedLengthElement): 

7 """ 

8 Represents a reference element in the schema. 

9 This is used to refer to other defined types. 

10 """ 

11 

12 type_name: str 

13 type_: FixedLengthElement = None # The type this reference points to. Set lazily 

14 offset: int|None = None # Offset in bytes, if applicable 

15 

16 @cached_property 

17 def total_length(self) -> int: 

18 return self.type_.total_length 

19 

20 

21 def lazy_bind(self, types): 

22 self.type_ = types[self.type_name] 

23