Skip to content

miniproto.tl.codec.decode_object

decode_object(data: bytes | memoryview, offset: int = 0, expected_type: str | None = None) -> tuple[Any, int]

Decode a primitive or generated TL object selected by its constructor.

Parameters:

  • data (bytes | memoryview) – TL wire bytes.
  • offset (int) – Starting byte offset, defaulting to 0.
  • expected_type (str | None) – Optional schema type used for primitive dispatch.

Returns:

  • tuple[Any, int] – Decoded value and first unread offset.

Raises:

  • TLCodecError – If the constructor is unknown or a bare type lacks a concrete class.