Skip to content

Commit 6507d47

Browse files
committed
added Protocol._get_payload for customisable payload retrieving methods
1 parent 32ad44a commit 6507d47

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pcapkit/protocols/protocol.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,18 @@ def __hash__(self) -> 'int':
744744
# Utilities.
745745
##########################################################################
746746

747+
def _get_payload(self) -> 'bytes':
748+
"""Get payload of :attr:`self.__header__ <Protocol.__header__>`.
749+
750+
Returns:
751+
Payload of :attr:`self.__header__ <Protocol.__header__>` as :obj:`bytes`.
752+
753+
See Also:
754+
This is a wrapper function for :meth:`pcapkit.protocols.schema.Schema.get_payload`.
755+
756+
"""
757+
return self.__header__.get_payload()
758+
747759
def _read_protos(self, size: int) -> 'Optional[StdlibEnum | AenumEnum]': # pylint: disable=unused-argument
748760
"""Read next layer protocol type.
749761
@@ -1103,7 +1115,7 @@ def _import_next_layer(self, proto: 'int', length: 'Optional[int]' = None, *,
11031115
if TYPE_CHECKING:
11041116
protocol: 'Type[Protocol]'
11051117

1106-
file_ = self.__header__.get_payload()
1118+
file_ = self._get_payload()
11071119
if length is None:
11081120
length = len(file_)
11091121

0 commit comments

Comments
 (0)