Skip to content

Commit

Permalink
Add data converter docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kg583 committed Sep 13, 2023
1 parent 0125c8f commit 8515106
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions tivars/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,21 @@ def set(cls, value: _T, **kwargs) -> bytes:


class Data(Bytes):
"""
No-op converter for data sections with associated metadata
The following metadata fields are automatically set by this converter:
- Version
"""

_T = bytes

@classmethod
def set(cls, value: _T, *, instance=None, **kwargs) -> _T:
"""
Converts ``bytes`` -> ``bytes`` and updates metadata fields
Certain metadata fields are updated automatically based on the entry's data.
The following are set by this converter:
- Version
- Length (for sized data)
:param value: The value to convert
:param instance: The instance which contains the data section
:return: The bytes in ``value``, unchanged
Expand All @@ -97,6 +99,15 @@ def set(cls, value: _T, *, instance=None, **kwargs) -> _T:


class SizedData(Data):
"""
No-op converter for sized data sections with associated metadata
The following metadata fields are automatically set by this converter:
- Version
- Length
"""

_T = bytes

@classmethod
Expand Down

0 comments on commit 8515106

Please sign in to comment.