Skip to content

encode_frame

autogen.beta.network.transport.frames.encode_frame #

encode_frame(frame)

Serialise a Frame to a JSON-compatible dict.

Adds the kind discriminator (a ClassVar, so asdict does not include it). Nested Envelope is auto-flattened by dataclasses.asdict.

Source code in autogen/beta/network/transport/frames.py
def encode_frame(frame: Frame) -> dict[str, Any]:
    """Serialise a Frame to a JSON-compatible dict.

    Adds the ``kind`` discriminator (a ``ClassVar``, so ``asdict`` does
    not include it). Nested ``Envelope`` is auto-flattened by
    ``dataclasses.asdict``.
    """
    data = asdict(frame)
    data["kind"] = frame.kind
    return data