3.0.ipv8.messaging.lazy_payload =============================== .. py:module:: 3.0.ipv8.messaging.lazy_payload Classes ------- .. autoapisummary:: 3.0.ipv8.messaging.lazy_payload.VariablePayload Functions --------- .. autoapisummary:: 3.0.ipv8.messaging.lazy_payload.vp_compile Module Contents --------------- .. py:class:: VariablePayload(*args: Any, **kwargs) Bases: :py:obj:`3.0.ipv8.messaging.serialization.Payload` A Payload instance which mimics a struct. Useful for when you want a less verbose way to specify Payloads. This class requires you to only specify your format in: - .format_list : a list of Serializer format specifications - .names : the field names to use for the given formats For instance: class MyPayload(VariablePayload): format_list = ['?'] names = ["is_this_a_boolean"] If you require field-specific pack/unpack operations you can specify them using the `fix_pack_*` and `fix_unpack_*` methods. Custom packing and unpacking rules can be useful for compression methods like socket.inet_aton, which you only want to apply when actually sending over the wire. .. py:attribute:: names :type: list[str] :value: [] .. py:method:: from_unpack_list(*args: Any) -> VariablePayload :classmethod: Given a list of raw arguments, initialize a new cls instance. If this class has special rules for certain fields, apply them. .. py:method:: _to_packlist_fmt(fmt: 3.0.ipv8.messaging.serialization.FormatListType) -> str :staticmethod: .. py:method:: _fix_pack(name: str) -> Any Check if there are custom rules for sending this field. .. py:method:: to_pack_list() -> list[tuple] Convert the VariablePayload to a Serializable pack list. This method will automatically pull from the available format names and set instance fields. :return: the pack list .. py:function:: vp_compile(vp_definition: type[T]) -> type[T] JIT Compilation of a VariablePayload definition.